<template>

    <rm-layout-top class="Corehidden" :canDrag=false :splitwidth=0 >
        <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" :title="poptitle" :visible.sync="dialogTableVisible" @close="popcommonclose" v-if="dialogTableVisible" ref="popcommondialog">
            <rm-pop-common @cancel="dialogTableVisible=false,popcommonclose()" :datatype="popdatatype" :rptunitid="selLibrid" @change="popchange" ref="popcommon"></rm-pop-common>
        </el-dialog>

        <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="样本类型编辑框" :visible.sync="addtypedialogTableVisible">
            <el-container style="height: 500px; border: 1px solid #eee">
            <el-main style="overflow: hidden;">
            <el-input @input="autosearch" @keydown.native="searchkeydown" placeholder="快速检索" prefix-icon="el-icon-search" ref="qcodeinput" style="width:300px;" v-model="qcode"></el-input>
            <el-button @click="btnok" icon="el-icon-circle-check" style="margin-left:10px;margin-top:3px;">确定</el-button>
            <el-button @click="btncancel" icon="el-icon-circle-close" style="margin-top:3px;">取消</el-button>
            <el-button style="float:right;margin-top:3px;" @click="refreshdata" icon="el-icon-refresh">刷新数据</el-button>
            <!-- <vxe-grid :columns="tableColumn" row-id='gridID'  :select-config="{checkRowKeys: StorageSmptypeInfo,reserve:true,trigger:'cell'}"  :pager-config="tablePage"  :data="tableData" @cell-dblclick="vxselect" border height="461px" show-header-overflow="tooltip" show-overflow="tooltip" highlight-current-row highlight-hover-row ref="ddlcommonTable" resizable size="mini" stripe style="margin-top:5px"></vxe-grid> -->
            <vxe-grid :columns="tableColumn" row-id='specimen_code'  :select-config="{showHeader:true, checkRowKeys: StorageSmptypeInfo,reserve:true,trigger:'cell'}"  :pager-config="tablePage"  :data="tableData" @cell-dblclick="vxselect" border height="461px" show-header-overflow="tooltip" show-overflow="tooltip" highlight-current-row highlight-hover-row ref="ddlcommonTable" resizable size="mini" stripe style="margin-top:5px"></vxe-grid>
            </el-main>
            </el-container>
        </el-dialog>

        <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="批量打印编辑框" :visible.sync="dialogPrintVisible" width="25%">
        <span>请输入登记序号段</span>
        <span slot="footer" class="dialog-footer">
            <table>
                <tr>
                    <td><el-input></el-input></td>
                    <td>-</td>
                    <td><el-input></el-input></td>
                </tr>
                 <tr>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr>
                    <td><el-button type="primary" @click="dialogPrintVisible = false" icon="el-icon-circle-check" style="margin-left:10px;margin-top:3px;">确 定</el-button></td>
                    <td></td>
                    <td><el-button  @click="dialogPrintVisible = false" icon="el-icon-circle-close" style="float:left;margin-top:3px;" >取 消</el-button></td>
                </tr>
            </table>
        </span>
        </el-dialog>


        <!-- <el-dialog :append-to-body="true" :close-on-click-modal="false" title="样本类型" :visible.sync="specimenVisible">
                <rm-pop-common @change="specimenChange" @cancel="specimenVisible = false;" datatype="specimen" :multiple="false"></rm-pop-common>
        </el-dialog> -->

        <template v-slot:fix>
            <div style="width:100%">
                <div style="float:left;width:100%">
                    <table>
                        <tr>
                            <td>
                                <el-button icon="el-icon-edit" ref="editedit" type="310">修改信息</el-button>
                            </td>
                            <td>
                                <!-- 刷新 -->
                                <el-button icon="el-icon-refresh" ref="editrefresh" type="310" @click="smpRegisterQuery">刷新</el-button>
                            </td>
                             <td>
                                <!-- 查询 仅测试用 -->
                                <el-button icon="el-icon-search" ref="editquery" type="310" @click="smpRegisterQuery">查询</el-button>

                            </td>
                            <td>
                                <!-- <el-button icon="el-icon-plus" @click="$refs.rmlabreport.$refs.rmlabresult.ResultAddAsync()" type="310" ref="btnadd" :disabled="btndisabled">新增(F2)</el-button> -->
                            </td>
                            <td style="text-align:left">
                                <el-button icon="el-icon-delete" @click="btnSmpRegisterDel" type="310" ref="btndel" :disabled="btndisabled">删除</el-button>
                            </td>

                            <td style="text-align:left">
                                <!-- <el-popover placement="bottom" title="上一个校验" width="200" trigger="click" :content="popoverSaveContent"> -->
                                <el-button icon="el-icon-arrow-left" @click="BtnPreviousNext($event,'previous')" type="310">上一个</el-button>
                                <!-- </el-popover> -->
                            </td>
                            <td>
                                <!-- <el-popover placement="bottom" title="下一个校验" width="200" trigger="click" :content="popoverSaveContent"> -->
                                <el-button icon="el-icon-arrow-right" @click="BtnPreviousNext($event,'next')" type="310">下一个</el-button>
                                <!-- </el-popover> -->
                            </td>
                            <td>
                                <!-- btnSave -->
                                <el-button icon="el-icon-document" slot="reference" @click="btnSave(true)" type="310">保存</el-button>
                            </td>
                            <td>
                                <el-button icon="el-icon-document"  type="310" :disabled="btndisabled">取消</el-button>
                            </td>
                            <td style="text-align:left">
                                <el-button icon="el-icon-printer" @click="btnPrintBarcode()" type="310">打印</el-button>
                            </td>
                            <td>
                                <el-button icon="el-icon-check" @click="dialogPrintVisible = true" type="310">批打</el-button>
                            </td>
                            <td style="text-align:left">
                                <el-button icon="el-icon-folder-checked" @click="$refs.rmlabreport.CollectDeal()" type="310">导出</el-button>
                            </td>
                            <!-- <td>
                                <el-button @click="$refs.rmlabreport.OpenConfig()" icon="el-icon-setting" type="310">设置</el-button>
                            </td> -->
                             <td style="text-align:left">
                                <el-dropdown>
                                    <el-button type="310">
                                        更多操作<i class="el-icon-arrow-down el-icon--right"></i>
                                    </el-button>
                                    <el-dropdown-menu slot="dropdown">
                                        <el-dropdown-item @click="RePrintBarcode">补打条码</el-dropdown-item>
                                        <el-dropdown-item @click="QueryRegisterLog">查看日志</el-dropdown-item>
                                        <el-dropdown-item :disabled="btndisabled" @click="ClearNoDoItems">清除未做</el-dropdown-item>
                                        <el-dropdown-item @click="ClearPrintFlag">清除打印标志</el-dropdown-item>
                                        <el-dropdown-item @click.native="OpenConfig">设置</el-dropdown-item>
                                    </el-dropdown-menu>
                                </el-dropdown>
                                <!--<el-button icon="el-icon-lock" type="310" @click="ALLSee()">锁定程序</el-button>-->
                            </td>
                            <td width="800" style="width:800px"></td>
                        </tr>
                    </table>
                </div>
            </div>
        </template>
        <div>

        </div>
        <rm-layout-left class="Corehidden" splitcolor="#DoderBlue" movingcolor="LightSteelBlue" :splitwidth="4" :fixsize="initScrollPosition" >
            <!-- <div class="pagecenter-left"> -->
            <template v-slot:fix>
                <rm-layout-top class="Corehidden"  splitcolor="#DoderBlue" movingcolor="LightSteelBlue"  :splitwidth="0" :fixsize="30"  :canDrag=false>
                    <template v-slot:fix>
                        <div class="pagecenter-left-1" ref="r-pagecenter-left-1" >
                            <table style=" width:850px; float:left;  overflow:hidden; border-spacing:3px;"  cellpadding="0" cellspacing="0" >
                                <tr style="width:100%;">
                                    <span class="sepcnoDate">
                                        <td  style="height:21px; overflow:hidden"   :style="{width: RegisterDateTitleWidth + 'px'}">
                                            <!-- <td  style="height:21px;width:60px; "  RegisterSeq > -->
                                            <div  style="text-overflow: ellipsis; overflow: hidden; white-space: nowrap;text-align:right; color: rgb(0, 149, 217);">
                                                {{RegisterDate.col_label}}
                                            </div>
                                        </td>
                                        <td style="width: 120px;height:21px;overflow:hidden" >

                                        <div  v-if="RegisterDate.valuetype=='7'">
                                            <el-date-picker v-model="selectdate"  @change="smpRegisterQuery('changeDate')" value-format="yyyy-MM-dd" :picker-options="pickerOptions" :clearable="false" ref="registerDate" style="width:100%; " ></el-date-picker>
                                        </div>
                                        </td>
                                    </span>
                                    <span>
                                        <td  style="height:21px;overflow:hidden "   :style="{width: RegisterTitleWidth + 'px'}">
                                        <!-- <td  style="height:21px;width:60px; " > -->
                                            <div  style="text-overflow: ellipsis; overflow: hidden; white-space: nowrap;text-align:right; color: rgb(0, 149, 217);">
                                                {{RegisterSeq.col_label}}
                                            </div>
                                        </td>
                                        <td style="width: 120px;height:21px;overflow:hidden" >
                                            <el-input v-model="specno" v-if="RegisterSeq.col_label=='登记序号'" type="text"   @change="smpRegisterQuery"  :ref="RegisterSeq.col_code"></el-input>
                                        </td>
                                    </span>

                                    <span ref="SampleBankWidth">
                                    <td  style="color:#0095d9;height:21px;overflow:hidden" :style="{width: SampleBankTitleWidth + 'px'}">
                                        <div style="text-align:right;">
                                            样本库
                                        </div>
                                    </td>
                                    <td  style="width: 120px;height:21px;overflow:hidden">
                                        <el-select v-model="selLibrid" filterable style="width:100%;"  ref="selLibrid" @change="LibridChange()">
                                            <!-- <el-option v-for="(item, index) in selSmpLibrary_Options" :key="index" :value="item.librname" :label="item.librid"></el-option> -->
                                            <el-option v-for="(item, index) in selSmpLibrary_Options" :key="index" :value="item.librid" :label="item.librname" ></el-option>
                                        </el-select>
                                    </td>
                                    </span>
                                </tr>
                            </table>
                        </div>
                    </template>
                    <rm-layout-top  splitcolor="#DoderBlue" style="overflow-y:hidden; " class="ScrollBarhidden" movingcolor="LightSteelBlue" :splitwidth="4" :fixsize="340" :minfixsize="380" :maxfixsize="560"   :canDrag=false>
                        <template v-slot:fix class="Corehidden" >
                            <div class="pagecenter-left-2"  ref="xTableDiv">
                                <table style="float:left;  overflow:hidden; border-spacing:3px; table-layout:fixed" class="tableleft">
                                    <tr v-for="(cols,index) in ColTotalData" :key="index" style="width:100%; display:block; margin:2px 0; height:26px;" >
                                        <!-- <span v-for="(item,index2) in cols" :key="item.col_code"  v-show="item.visibled" style="display:block: width:100px;overflow:hidden;text-overflow:ellipsis;"> -->
                                        <span v-for="(item,index2) in cols" :key="item.col_code"  v-show="item.visibled" style="display:block: width:100px;overflow:hidden;text-overflow:ellipsis;">
                                            <td  style="height:21px; " :style="{width: HisTdWidth[index2] + 'px'}">
                                                <div  style="text-overflow: ellipsis; overflow: hidden; white-space: nowrap;text-align:right;">
                                                    {{item.col_label}}
                                                </div>
                                            </td>
                                            <td style="width: 120px;height:21px; " >
                                                <el-tooltip class="item" effect="light" placement="top-start" :disabled="tooltipsdiable">
                                                    <div slot="content" style="width:160px">{{tooltipcontent}}</div>

                                                    <!-- <el-input v-model="PatientInfo[item.col_code]" v-if="item.col_code==='pat_ageyear'" type="text"  size="mini" :readonly="true" :disabled="true" :ref="item.col_code" ></el-input> -->
                                                    <div v-if="item.valuetype=='1'" >
                                                        <el-radio-group v-if="item.col_code=='istransfer'"  v-model="PatientInfo[item.col_code]" :ref="item.col_code" v-show="item.visibled" onkeydown="if(event.keyCode==9){event.returnValue=false;} " @keyup.tab.native="EnterEvent(item.col_code)"   @change="inputChangeEvent($event,item.col_code)">
                                                            <el-radio-button  :label="'1'"  style="vertical-align: middle;" >是</el-radio-button>
                                                            <el-radio-button  :label="'0'"  style="vertical-align: middle;" >否</el-radio-button>
                                                        </el-radio-group>
                                                        <el-radio-group v-if="item.col_code=='isoperation'" v-model="PatientInfo[item.col_code]" :ref="item.col_code" v-show="item.visibled" onkeydown="if(event.keyCode==9){event.returnValue=false;} " @keyup.tab.native="EnterEvent(item.col_code)"  @change="inputChangeEvent($event,item.col_code)">
                                                            <el-radio-button  :label="'1'"  style="vertical-align: middle;" >是</el-radio-button>
                                                            <el-radio-button  :label="'0'"  style="vertical-align: middle;" >否</el-radio-button>
                                                        </el-radio-group>
                                                        <el-radio-group v-if="item.col_code=='antivirus'" v-model="PatientInfo[item.col_code]" :ref="item.col_code" v-show="item.visibled" onkeydown="if(event.keyCode==9){event.returnValue=false;} " @keyup.tab.native="EnterEvent(item.col_code)"  @change="inputChangeEvent($event,item.col_code)">
                                                            el-radio-button  :label="'1'"  style="vertical-align: middle;" >是</el-radio-button>
                                                            <el-radio-button  :label="'0'"  style="vertical-align: middle;" >否</el-radio-button>
                                                        </el-radio-group>
                                                    </div>
                                                    <div  v-else-if="item.valuetype=='2'">
                                                        <el-input v-model="PatientInfo[item.col_code]" v-if="item.col_code=='smp_registerno'" type="text"  size="mini" v-show="item.visibled" :readonly="true" :disabled="true" :ref="item.col_code"  @keyup.enter.native="EnterEvent(item.col_code)" @mouseover.native="tooltipmousover(item.col_code,item.valuetype)"></el-input>
                                                        <el-input v-model="PatientInfo[item.col_code]" v-else-if="item.col_code === 'pat_agestr'" @keyup.enter.native="EnterEvent(item.col_code)" v-show="item.visibled" :disabled="!item.enabled"  @keyup.space.native="SpaceEvent(item.col_code)" @keyup.up.native="InputMove(0, item.col_code)" @keyup.down.native="InputMove(1, item.col_code)" @dblclick.native="inputdblEvent(item.col_code)" @change="popinputchange($event, item.col_code)" @focus="InputFocus(item.col_code)" :readonly="item.noedit" @mouseover.native="tooltipmousover(item.col_code,item.valuetype)" size="mini" :ref="item.col_code"></el-input>
                                                        <el-input v-model="PatientInfo[item.col_code]" v-else-if="item.col_code === 'req_reason'" @keyup.enter.native="EnterEvent(item.col_code)" v-show="item.visibled" :disabled="!item.enabled"  @keyup.space.native="SpaceEvent(item.col_code)" @keyup.up.native="InputMove(0, item.col_code)" @keyup.down.native="InputMove(1, item.col_code)" @dblclick.native="reqdbleclick('1')" @focus="InputFocus(item.col_code)" @mouseover.native="tooltipmousover(item.col_code,item.valuetype)" size="mini" :ref="item.col_code"></el-input>
                                                        <el-input v-model="PatientInfo[item.col_code]" v-else-if="item.col_code!='smp_registerno'" type="text"  size="mini" v-show="item.visibled"  :ref="item.col_code" :disabled="!item.enabled"  @keyup.enter.native="EnterEvent(item.col_code)"  @change="inputChangeEvent($event,item.col_code)" @keyup.up.native="InputMove(0,item.col_code)" @keyup.down.native="InputMove(1,item.col_code)" @focus="InputFocus(item.col_code)" @mouseover.native="tooltipmousover(item.col_code,item.valuetype)"></el-input>

                                                    </div>
                                                    <el-select v-model="PatientInfo[item.col_code]" v-else-if="item.valuetype=='3'"  v-show="item.visibled"  :ref="item.col_code" onkeydown="if(event.keyCode==9){event.returnValue=false;} " @keyup.tab.native="EnterEvent(item.col_code)"  @mouseover.native="tooltipmousover(item.col_code,item.valuetype)" @change="inputChangeEvent($event,item.col_code)" >
                                                    <!-- <el-option v-for="item in item.col_code" :key="item" :value="item" :label="item"></el-option> -->
                                                        <el-option v-for="(item,index) in popdropdwon_Options[item.col_code]" :key="index" :value="item.key" :label="item.value" ></el-option>
                                                    </el-select>
                                                    <el-input v-model="PatientInfo[item.col_code+'name']" v-else-if="item.valuetype=='5'" type="text" size="mini" :ref="item.col_code" v-show="item.visibled" :readonly="item.noedit"   @keyup.enter.native="EnterEvent(item.col_code)" @keyup.space.native="SpaceEvent(item.col_code)" @keyup.up.native="InputMove(0, item.col_code)" @keyup.down.native="InputMove(1, item.col_code)"  @focus="InputFocus(item.col_code)" @dblclick.native="inputdblEvent(item.col_code)" @change="popinputchange($event,item.col_code)" @mouseover.native="tooltipmousover(item.col_code,item.valuetype)" ></el-input>
                                                    <!-- <el-date-picker v-model="PatientInfo[item.col_code]" v-else-if="item.valuetype==='7'" v-show="item.visibled" type="datetime" value-format="yyyy-MM-dd HH:mm:ss"  align="right" size="mini" :ref="item.col_code"></el-date-picker> -->
                                                    <div v-else-if="item.valuetype==='7'">
                                                        <el-date-picker v-model="PatientInfo[item.col_code]" v-if="item.col_code=='smp_registerdate'" size="mini" align="right"    :clearable="false" v-show="item.visibled"   value-format="yyyy-MM-dd"    :disabled="true" :ref="item.col_code"  style="width:120px;"  onkeydown="if(event.keyCode==9){event.returnValue=false;} "  @keyup.enter.native="EnterEvent(item.col_code)" @mouseover.native="tooltipmousover(item.col_code,item.valuetype)" >
                                                        </el-date-picker>
                                                    <!-- <el-date-picker v-model="PatientInfo[item.col_code]" v-if="item.col_code!='smp_registerdate'" size="mini"   v-show="item.visibled"  :clearable="false"  prefix-icon ="false"  type="datetime" value-format="yyyy-MM-dd HH:mm:ss"    :ref="item.col_code" style="width:120px;"  onkeydown="if(event.keyCode==9){event.returnValue=false;} " @keyup.tab.native="EnterEvent(1,item.col_code)" @keyup.enter.native="EnterEvent(item.col_code)" @keyup.up.native="InputMove(0, item.col_code)" @keyup.down.native="InputMove(1, item.col_code)" :disabled="!item.enabled" @focus="InputFocus(item.col_code)"   @mouseover.native="tooltipmousover(item.col_code,item.valuetype)"   ></el-date-picker>
                                                    -->
                                                        <el-date-picker v-model="PatientInfo[item.col_code]" v-else-if="item.col_code!='smp_registerdate'" class="smpPicker" style="width:100%"  v-show="item.visibled" size="mini" :ref="item.col_code" type="datetime"  value-format="yyyy-MM-dd HH:mm:ss"  @keyup.enter.native="EnterEvent(item.col_code)" @keyup.up.native="InputMove(0,item.col_code)" @keyup.down.native="InputMove(1,item.col_code)"  @focus="InputFocus(item.col_code)"  >
                                                        </el-date-picker>
                                                    </div>
                                                </el-tooltip>
                                            </td>
                                        </span>
                                    </tr>
                                </table>
                            </div>
                        </template>
                        <div class="pagecenter-left-3-1" >
                            <vxe-table  :data.sync="xTableSpecimenTypeV" border fit  height="auto" header-align="center" highlight-current-row highlight-hover-row ref="xTableSpecimenType" resizable show-header-overflow="tooltip" show-overflow="tooltip" size="mini" stripe @header-cell-dblclick="addsmptype" @cell-click="addvxedetail"  >
                                <vxe-table-column width="30px" field="ischk"  header-align="center" align="center">
                                    <template v-slot="{row}">
                                        <el-checkbox true-label="1" false-label="0" v-model="row.ischk"  ></el-checkbox>
                                    </template>
                                </vxe-table-column>
                                <vxe-table-column field="specimen_name" title="样本类型双击" width="90px"  >
                                    <template v-slot:header="{column}" >
                                        <vxe-tooltip content='双击添加样本类型!'    >
                                            <div >{{column.title}}<i class="el-icon-first-aid-kit"></i></div>
                                        </vxe-tooltip>
                                    </template>
                                </vxe-table-column>
                                <vxe-table-column v-if="false" field="specimen_code" title="样本类型代码" width="40px"></vxe-table-column>
                                <vxe-table-column v-if="false" field="librID" title="样本库ID" width="40px"></vxe-table-column>
                                <vxe-table-column field="quantity" title="份数" width="45px"></vxe-table-column>
                                <vxe-table-column field="volume" title="标本量" width="55px"></vxe-table-column>
                                <vxe-table-column field="unit" title="单位" width="45px"></vxe-table-column>
                                <template v-slot:empty style="width:150px;">
                                <span style="color: red; ">请双击样本类型(添加)</span>
                                </template>
                            </vxe-table>
                        </div>
                        <div class="pagecenter-left-3-2">
                           <vxe-table  :data.sync="DetailTableData" border fit :mouse-config="{selected: true}" height="auto" header-align="center" highlight-current-row highlight-hover-row ref="xTableDetail" resizable show-header-overflow="tooltip" show-overflow="tooltip" size="mini" stripe  class="detailClass" :edit-config="{trigger: 'click', mode: 'cell', showStatus: true}"  :row-class-name="rowClassName" @cell-click="adddetailprint"  @cell-dblclick="dbldelDetail">
                                <vxe-table-column field="ischk" title="选择" width="30px"  header-align="center" align="center">
                                    <template v-slot="{row}">
                                        <el-checkbox true-label="1" false-label="0" v-model="row.ischk"></el-checkbox>
                                    </template>
                                </vxe-table-column>
                                <vxe-table-column v-if="false" field="smp_regdetailid" title="登记明细ID" width="40px"></vxe-table-column>
                                <vxe-table-column v-if="false" field="smp_registerid" title="登记ID" width="40px"></vxe-table-column>
                                <vxe-table-column v-if="false" field="smp_type" title="样本代码" width="85px"></vxe-table-column>
                                <vxe-table-column field="specimen_name" title="样本类型" width="85px"></vxe-table-column>
                                <vxe-table-column field="smp_number" title="份数"  :edit-render="{name: 'input'}" width="50px"></vxe-table-column>
                                <vxe-table-column field="smp_quantity" title="标本量"  :edit-render="{name: 'input'}" width="60px"></vxe-table-column>
                                <vxe-table-column field="smp_unit" title="单位"  :edit-render="{name: 'input'}" width="50px"></vxe-table-column>
                                <vxe-table-column field="smp_sumprint" title="已打数量"  :edit-render="{name: 'input'}" width="70px"></vxe-table-column>
                                <vxe-table-column field="isbarcodeprint" title="已打印" width="60px"   header-align="center" align="center" >
                                    <template v-slot="{row}">
                                        <el-checkbox true-label="1" false-label="0" :disabled="true" v-model="row.isbarcodeprint"></el-checkbox>
                                    </template>
                                </vxe-table-column>
                            </vxe-table>
                        </div>
                    </rm-layout-top>
                </rm-layout-top>

            </template>
            <!-- 440 -->
            <rm-layout-top splitcolor="#DoderBlue" movingcolor="	LightSteelBlue" :splitwidth="4" :fixsize="370" :minfixsize="300" :maxfixsize="700" :canDrag=false>
                <template v-slot:fix class="rightTableTop">
                    <vxe-table  :data.sync="RegisterTableData" border fit  height="auto" header-align="center" align="center" highlight-current-row scroll  ref="xTable" resizable show-header-overflow="tooltip" show-overflow="tooltip" size="mini" stripe   @cell-click="RegisterRowClick()"  >

                        <vxe-table-column v-if="false" field="smp_registerid" title="标本登记id"  width="40px"></vxe-table-column>
                        <!-- <vxe-table-column field="status" title="状态" width="50px" :formatter="registerStatusDisplay" :filters="[{label: '登记', value: '10'},{label: '打印', value: '20'},{label: '入库', value: '30'},{label: '使用', value: '40'},{label: '作废', value: '90'}]" ></vxe-table-column> -->
                        <vxe-table-column field="status" title="登记状态" width="60px" :formatter="registerStatusDisplay" ></vxe-table-column>
                        <vxe-table-column field="smp_registerno" title="登记序号" width="80px"></vxe-table-column>
                        <vxe-table-column field="pat_no" title="病人号" width="60px"></vxe-table-column>
                        <vxe-table-column field="pat_cardno" title="就诊卡号" width="80px"></vxe-table-column>
                        <vxe-table-column field="pat_name" title="病人姓名" width="80px"></vxe-table-column>
                        <vxe-table-column v-if="false" field="pat_sex" title="性别" width="40px"></vxe-table-column>
                        <vxe-table-column field="pat_sexname" title="性别" width="40px"></vxe-table-column>
                        <vxe-table-column field="pat_birth" title="病人生日" width="80px"></vxe-table-column>
                        <vxe-table-column field="pat_agestr" title="年龄" width="40px"></vxe-table-column>
                        <!-- <vxe-table-column field="pat_agestrname" title="年龄" width="40px"></vxe-table-column> -->
                        <vxe-table-column field="pat_ageyear" title="岁数" width="40px"></vxe-table-column>
                        <vxe-table-column v-if="false" field="pat_typecode" title="病人类型" width="80px"></vxe-table-column>
                        <vxe-table-column field="pat_typecodename" title="病人类型" width="80px"></vxe-table-column>
                        <vxe-table-column field="pat_address" title="病人联系地址" width="150px"></vxe-table-column>
                        <vxe-table-column field="pat_nation" title="国籍" width="40px"></vxe-table-column>
                        <vxe-table-column field="pat_idcardno" title="身份证/护照" width="250px"></vxe-table-column>
                        <vxe-table-column field="pat_height" title="身高" width="40px"></vxe-table-column>
                        <vxe-table-column field="weight" title="体重" width="40px"></vxe-table-column>
                        <vxe-table-column field="abo_bldtype" title="abo血型" width="80px"></vxe-table-column>
                        <vxe-table-column field="rh_bldtype" title="rh血型" width="80px"></vxe-table-column>
                        <vxe-table-column v-if="false" field="req_deptno" title="申请科室" width="80px"></vxe-table-column>
                        <vxe-table-column field="req_deptnoname" title="申请科室" width="80px"></vxe-table-column>
                        <vxe-table-column field="pat_class" title="病人分类" width="80px"></vxe-table-column>
                        <vxe-table-column field="pat_sourcetype" title="标本来源" width="80px" :formatter="formatFun"></vxe-table-column>
                        <vxe-table-column field="hospitalname" title="外院名称" width="80px"></vxe-table-column>
                        <vxe-table-column field="sourcecode" title="来源编号" width="80px"></vxe-table-column>
                        <vxe-table-column field="familyornot" title="家族史" width="60px"></vxe-table-column>
                        <vxe-table-column field="tumorsize" title="肿瘤大小" width="80px"></vxe-table-column>
                        <vxe-table-column field="tumornumber" title="肿瘤个数" width="80px"></vxe-table-column>
                        <vxe-table-column field="lymphanumber" title="淋巴结数" width="80px"></vxe-table-column>
                        <vxe-table-column field="istransfer" title="远处转移" width="80px" :formatter="CheckStatusDisplay" ></vxe-table-column>
                        <vxe-table-column field="tnm" title="tnm" width="60px"></vxe-table-column>
                        <vxe-table-column field="isoperation" title="是否手术" width="80px" :formatter="CheckStatusDisplay"></vxe-table-column>
                        <vxe-table-column field="postoperativedays" title="术后天数" width="80px"></vxe-table-column>
                        <vxe-table-column field="operationdate" title="手术日期" width="80px"></vxe-table-column>
                        <vxe-table-column field="smpdate" title="留样日期" width="80px"></vxe-table-column>
                        <vxe-table-column field="remarks" title="备注" width="40px"></vxe-table-column>
                        <vxe-table-column field="smp_registeruser" title="登记人" width="80px"></vxe-table-column>
                        <vxe-table-column field="pat_diag" title="初诊" width="40px"></vxe-table-column>
                        <vxe-table-column field="smp_registerdate" title="登记日期" width="100px"></vxe-table-column>
                        <vxe-table-column field="originbarcode" title="检验条码" width="80px"></vxe-table-column>
                        <vxe-table-column field="pathology1" title="肉眼所见" width="80px"></vxe-table-column>
                        <vxe-table-column field="pathology2" title="镜下所见" width="80px"></vxe-table-column>
                        <vxe-table-column field="pathology3" title="免疫组化" width="80px"></vxe-table-column>
                        <vxe-table-column field="passagecnt" title="传代次数" width="80px"></vxe-table-column>
                        <vxe-table-column field="strains" title="菌株" width="40px"></vxe-table-column>
                        <vxe-table-column field="strainsproperty" title="菌株属性" width="80px"></vxe-table-column>
                        <vxe-table-column field="cellbatchno" title="细胞批号" width="80px"></vxe-table-column>
                        <vxe-table-column field="passagenum" title="细胞代次编号" width="80px"></vxe-table-column>
                        <vxe-table-column field="cellclass" title="细胞类别" width="80px"></vxe-table-column>
                        <vxe-table-column field="celllevel" title="细胞等级" width="80px"></vxe-table-column>
                        <vxe-table-column field="cellqcflag" title="细胞质控标志" width="80px"></vxe-table-column>
                        <vxe-table-column field="diseases" title="疾病种类" width="80px"></vxe-table-column>
                        <vxe-table-column field="reserve1" title="备用1" width="80px"></vxe-table-column>
                        <vxe-table-column field="reserve2" title="备用2" width="80px"></vxe-table-column>
                        <vxe-table-column field="reserve3" title="备用3" width="80px"></vxe-table-column>
                        <vxe-table-column field="reserve4" title="备用4" width="80px"></vxe-table-column>
                        <vxe-table-column field="reserve5" title="备用5" width="80px"></vxe-table-column>
                        <vxe-table-column field="reserve6" title="备用6" width="80px"></vxe-table-column>
                        <vxe-table-column field="reserve7" title="备用7" width="80px"></vxe-table-column>
                        <vxe-table-column field="reserve8" title="备用8" width="80px"></vxe-table-column>
                        <vxe-table-column field="reserve9" title="备用9" width="80px"></vxe-table-column>
                        <vxe-table-column field="reserve10" title="备用10" width="80px"></vxe-table-column>

                    </vxe-table>
                </template>
                <div @contextmenu.prevent="RightClick" style="height:100%">
                <vxe-table  :data.sync="SampleTableData"  row-id='smp_barcode' style="height:100%;" :auto-resize="true"   :select-config="{checkRowKeys:SampleIdKeys,showHeader:true,reserve:false,trigger:'cell'}"   border fit :mouse-config="{selected: true}"  height="auto" header-align="center" highlight-current-row highlight-hover-row ref="xTableSample" stripe resizable show-header-overflow="tooltip" show-overflow="tooltip" size="mini" >
                    <vxe-table-column v-if="false" field="smp_sampleid" title="样本ID" width="40px"></vxe-table-column>
                    <vxe-table-column v-if="false" field="smp_registerid" title="标本登记ID" width="40px"></vxe-table-column>
                    <vxe-table-column v-if="false" field="smp_registerdate" title="登记日期" width="40px"></vxe-table-column>
                    <vxe-table-column v-if="false" field="smp_registerno" title="标本登记序号" width="40px"></vxe-table-column>
                    <vxe-table-column type="selection" header-align="center" align="center"  width="40px" ></vxe-table-column>
                    <vxe-table-column field="smp_barcode" title="条码号" width="100px"></vxe-table-column>
                    <!-- <vxe-table-column field="smp_typename" title="标本类型" width="80px"></vxe-table-column> -->
                    <vxe-table-column field="specimen_name" title="标本类型" width="80px"></vxe-table-column>
                    <vxe-table-column field="smp_quantity" title="标本量" width="60px"></vxe-table-column>
                    <vxe-table-column field="smp_unit" title="单位" width="50px"></vxe-table-column>
                    <vxe-table-column field="smp_status" title="打印状态" width="60px" :formatter="sampleStatusDisplay"></vxe-table-column>
                    <vxe-table-column field="quantitystatus" title="标本余量" width="80px"></vxe-table-column>
                    <!-- <vxe-table-column field="smp_comments" title="标本备注" width="120px"></vxe-table-column> -->
                    <vxe-table-column field="smp_registerid" title="标本位置id" width="100px"></vxe-table-column>
                    <vxe-table-column field="indate" title="最后入库日期" width="100px"></vxe-table-column>
                    <vxe-table-column field="inuser" title="入库人" width="60px"></vxe-table-column>
                    <vxe-table-column field="lenddate" title="最后借出日期" width="100px"></vxe-table-column>
                    <vxe-table-column field="lenduser" title="借出人" width="60px"></vxe-table-column>
                    <vxe-table-column field="finishdate" title="完成日期" width="100px"></vxe-table-column>
                    <vxe-table-column field="finishuser" title="完成人" width="60px"></vxe-table-column>
                    <vxe-table-column field="outdate" title="抛弃日期" width="100px"></vxe-table-column>
                    <vxe-table-column field="outuser" title="抛弃人" width="60px"></vxe-table-column>
                    <vxe-table-column field="lendtime" title="借出次数" width="80px"></vxe-table-column>
                    <vxe-table-column field="smp_comments" title="标本备注" width="80px"></vxe-table-column>
                    <vxe-table-column field="smp_part" title="采集部位" width="80px"></vxe-table-column>
                    <vxe-table-column field="preoutdate" title="预销毁日期" width="80px"></vxe-table-column>
                    <vxe-table-column field="sourcetype" title="样本来源" width="80px" :formatter="formatFun"></vxe-table-column>
                    <vxe-table-column field="storerequire" title="标本存放要求" width="80px"></vxe-table-column>
                    <vxe-table-column field="maxtemp" title="存放最高温度" width="80px"></vxe-table-column>
                    <vxe-table-column field="mintemp" title="存放最低温度" width="80px"></vxe-table-column>
                    <vxe-table-column field="bottletype" title="存储容器类型" width="80px"></vxe-table-column>
                    <vxe-table-column field="createdt" title="创建时间" width="80px"></vxe-table-column>
                    <vxe-table-column field="createuser" title="创建人" width="80px"></vxe-table-column>
                </vxe-table>
                </div>
            </rm-layout-top>

        </rm-layout-left>
      <rm_ElementConfig ref="ElementConfig" :librid="selLibrid"  :tableDataColumn="tableDataColumn" :ConfigDetail="ConfigDetail" @configDefChange="configDefChange" @close="ConfigClose" ></rm_ElementConfig>
    </rm-layout-top>
</template>

<script type="text/javascript">
import Contextmenu from "vue-contextmenujs";
import { Promise } from "q";
import { invalid } from "moment";
import XE from "xe-utils"; //引入工具类
import { EleResize } from '../../../common/esresize';
import { compose } from 'element-ui/packages/table/src/util';
import rm_ElementConfig from '../../../rmcompents/rm_ElementConfig';
// import { EleResize } from '../../../../rmcompents/';

var formatDate = function (date) {
    var y = date.getFullYear();
    var m = date.getMonth() + 1;
    m = m < 10 ? ('0' + m) : m;
    var d = date.getDate();
    d = d < 10 ? ('0' + d) : d;
    var h = date.getHours();
    var minute = date.getMinutes();
    minute = minute < 10 ? ('0' + minute) : minute;
    var second= date.getSeconds();
    second = minute < 10 ? ('0' + second) : second;
    return y + '-' + m + '-' + d+' '+h+':'+minute+':'+ second;
};


 const ObjType = {
  isObject(obj) {
    return getObjType(obj) === "Object";
  },
  isArray(obj) {
    return getObjType(obj) === "Array";
  },
  isString(obj) {
    return getObjType(obj) === "String";
  },
  isNumber(obj) {
    return getObjType(obj) === "Number";
  },
  isBoolean(obj) {
    return getObjType(obj) === "Boolean";
  },
  isSymbol(obj) {
    return getObjType(obj) === "Symbol";
  },
  isFunction(obj) {
    return getObjType(obj) === "Function";
  },
  isNull(obj) {
    return getObjType(obj) === "Null";
  },
  isUndefined(obj) {
    return getObjType(obj) === "Undefined";
  },
  isFormData(obj) {
    return getObjType(obj) === "FormData";
  },
   isData(obj) {
    return getObjType(obj) === "[object Date]";
  },
  isFile(obj) {
    return getObjType(obj) === "File";
  }
};

/**
 * 对象的深度相等比较,不考虑指针,只比较值
 * 需要特别注意的是,比较之前已经对数据进行了深度trim处理
 * @param {*} obj 第一个对象
 * @param {*} obj2 第二个对象
 */
 function deepEqual(obj, obj2) {
  obj = deepTrim(obj);
  obj2 = deepTrim(obj2);
  return _deepEqual(obj, obj2);
  function _deepEqual(obj, obj2) {
    if (getObjType(obj) !== getObjType(obj2)) {
      return false;
    }
    if (ObjType.isObject(obj)) {
      const keys1 = Object.keys(obj);
      const keys2 = Object.keys(obj2);
      if (keys1.length !== keys2.length) {
        return false;
      }
      return keys1.every(key => {
        return _deepEqual(obj[key], obj2[key]);
      });
    } else if (ObjType.isArray(obj)) {
      if (obj.length !== obj2.length) {
        return false;
      }
      return obj.every((item, i) => {
        return _deepEqual(obj[i], obj2[i]);
      });
    } else if (ObjType.isFormData(obj)) {
      const arr1 = [...obj];
      const arr2 = [...obj2];
      if (arr1.length !== arr2.length) {
        return false;
      }
      return arr1.every((kv, idx) => {
        const [k1, v1] = arr1[idx];
        const [k2, v2] = arr2[idx];
        if (k1 !== k2) {
          return false;
        }
        if (getObjType(v1) !== getObjType(v2)) {
          return false;
        }
        if (ObjType.isFile(v1)) {
          const keys = ["name", "size", "type"];
          return keys.every(key => {
            return v1[key] === v2[key];
          });
        } else {
          return v1 === v2;
        }
      });
    }
    else if (obj instanceof Date && obj2 instanceof Date) {
        return obj.getTime() == obj2.getTime();
    }
    else {
      return obj === obj2;
    }
  }
}

/**
 * 获取元素类型,比如数组是Array,对象是Object,字符串是String
 * @param {*} obj
 * @returns {string}
 */
 function getObjType(obj) {
  const typeStr = Object.prototype.toString.call(obj);
  return typeStr.replace(/\[object (\w+)\]/, "$1");
}


/**
 * 对对象进行深层trim
 */
 function deepTrim(data) {
  return _deepTrim(data);
  function _deepTrim(data) {
    if (ObjType.isFormData(data)) {
      const formData = new FormData();
      const iterator = data.entries();
      const items = [];
      // eslint-disable-next-line no-constant-condition
      while (true) {
        const { value, done } = iterator.next();
        if (done) {
          break;
        }
        const name = value[0];
        let val = value[1];
        if (ObjType.isString(val)) {
          val = val.trim();
        }
        items.push([name, val]);
      }
      items.forEach(item => {
        const [name, val] = item;
        formData.append(name, val);
      });
      return formData;
    } else if (ObjType.isObject(data) || ObjType.isArray(data)) {
      const obj = ObjType.isObject(data) ? {} : [];
      for (const i in data) {
        obj[i] = _deepTrim(data[i]);
      }
      return obj;
    } else if (ObjType.isString(data)) {
      return data.trim();
    } else {
      return data;
    }
  }
}


function myTrim(x) {
    if ( Object.prototype.toString.call(x) === "[object String]") {
         return x.replace(/^\s+|\s+$/gm,'');
    }
  return x;
}

export default {
  components: { rm_ElementConfig },
    name: "SMP210",
    data() {
        return {
            /**top */
            specno: "1",
            selectdate: XE.toDateString(new Date(), "yyyy-MM-dd"),
            pickerOptions: {
                shortcuts: [
                    {
                        text: "今天",
                        onClick(picker) {
                            picker.$emit("pick", XE.toDateString(new Date(), "yyyy-MM-dd 00:00:00"));
                        },
                    },
                ],
            }, //日期配置将时间切换到当天
            selLibrid: "", //样本库ID
            txtSearch: "", //待定
            ddlSmp_startdt: XE.toDateString(XE.getWhatDay(new Date(), -7), "yyyy-MM-dd"), //操作日期-开始
            ddlSmp_enddt: XE.toDateString(new Date(), "yyyy-MM-dd"), //操作日期-结束

            //left-top
            //tableDataColumn: [], //设置弹窗的全部列数据
            ColData: [], //左侧显示列数据
            ColTotalData: [], //左侧全部显示列数据
            PatientInfo: {}, //病人信息
            StoragePatientInfo:{},
            //PatientInfo: [], //病人信息
            OldPatientInfo: {}, //旧病人信息
            barcodePatientInfo: {}, //有提示消息时需要确认才显示的病人信息
            RegisterTitleObject: [], //针对于登记日期、登记序号绑定的对象RegisterTitleObject
            RegisterDate:{},
            RegisterSeq:{},
            RegisterDateTitleWidth:60,  //登记日期默认60 px
            RegisterTitleWidth:60,  //登记序号默认60 px
            SampleBankTitleWidth:60, //样本库默认60 px
            HisTdWidth:[], //病人信息窗口label宽度
            //initScrollPosition:545,
            initScrollPosition:720,

            tooltipcontent: "", //His样本信息显示的提示内容
            Options: {}, //选项
            InputCodeArr: [], //ddl数据列表
            poptitle: "", //左侧列表通用弹出框标题
            popdatatype: "SMP210_charge_typeno", //左侧列表通用弹出框类型
            dialogTableVisible: false, //左侧通用弹窗
            addtypedialogTableVisible:false,//样本类型添加提示框
            dialogPrintVisible:false, //批量打印弹窗
            tooltipsdiable: false, //左侧列显示提示标志
            popoverSaveContent:"", //录入样本库信息时  样本库ID校验
            istransfer:'0',   //远处转移 0否 1是
            isoperation:'0',   //是否手术 0否 1是
            antivirus:'0',   //抗病毒治疗 0否 1是

            changekeyflag: false, //数据改变标志

            /**vxe-table 样本登记表 */
            loading: false,         //样本登记表vxe-table loading


            /**vxe-table 样本类型 */
            xTableSpecimenTypeV:[], //样本类型vxe-table数据源
            loadingType:false,      //样本类型 vxe-table loading

            /**vxe-table 样本登记明细 */
            DetailLoading:false,    //样本登记明细表 vxe-table loading

            /**vxe-table 打印的样本信息 */
            SampleLoading:false,    //样本信息表 vxe-table loading
            SampleIdKeys:[],

            /**样本类型弹窗 */
            tableData: null,   //grid 数据源
            tableColumn: [],   //grid 列数据源
            multiple: true,    //是否设置多选列
            fulldata: null,    //绑定的全部列数据
            dialogtxtSearch:'',//弹框样本类型的筛选条件
            qcode: "",         //弹窗过滤watch监听变量
            tablePage: {       //分页大小
                pageSize: 1000,
            },
            localName:null,   //本地样本类型

            /**其他 */
            btndisabled: false,
            tempIndex: 0,
            selSmpLibrary_Options: [],
            popdropdwon_Options: [],
            RegisterTableData: [],
            SampleTypeData:[],
            DetailTableData:[],
            SampleTableData:[],
            logTableData: [],
            PRGNO: "1",
            librid: "",
            trNum:0,
            tdNum:0,

            /**右键菜单 */
            //宽度
            resultw: "400px", //结果控件默认宽度

            //SMP210页面storage相关的对象
            //1.样本类型缓存对象
            StorageSmptypeInfo:[],

            /**rm_ElementConfig弹窗*/
            tableDataColumn: [], //设置弹窗的全部列数据
            ConfigDetail: {}, //tab页配置选项  改成json对象，方便后续再增加选项

            /**打印变量 */
            barcodestyle: "",
        };
    },
    //  components: { rmLabReportCollect, rmLabReportConfig },
    // components: {  rmLabReportConfigRmPopCommon2 },
    components: {  rm_ElementConfig },
    created() {
        //this.dataLoad();  //初始化 vue中data变量的字段
        this.ddlSmp_Library();//初始化样本库下拉框(附带默认查询)
        this.InitPageDate(); //初始化样本库日期
        this.loadPrintInfo();

    },
    mounted() {

        //console.log('单选框初始化🚀',this.$refs);
        // 监听body上的点击
        document.querySelector("body").addEventListener("click", this.closeMenu);
        // this.RResult(this.$route.fullPath, this);
        // this.QueryCol();

        //手动调用 popcommon初始化数据
        //this.$refs.popcommon.loadAllData();
        // window.addEventListener('keydown', event => {
        //     console.log('按下' + event.key)
        //     console.log('keycode:' + event.keyCode)
        //     console.log('thiscode:' + this.code)
        //     if (event.key === 'Tab') {
        //         console.log('tabfalse13')
        //         event.preventDefault()
        //     }
        // })

    },
    //
    beforeDestroy() {
        // 移除监听
        document.querySelector("body").removeEventListener("click", this.closeMenu);
        // window.removeEventListener('keydown', event => {
        // console.log(event.value)
        // event.preventDefault()
        // })
    },

    updated() {},
    // beforeRouteEnter(to, from, next) {
    //     next((vm) => {
    //         // 通过 `vm` 访问组件实例
    //         console.log("vm", vm);
    //         // vm.$refs.rmlabreport.RegKeyEvent();
    //     });
    // },
    methods: {
        /*-----------------------------初始化-----------------------------*/
        //条码打印信息加载
        loadPrintInfo()
        {
              this.$tool
                .request({
                    url: "SMP/SMP1/SMP190",
                    method: "post",
                    data: {
                        action: "getoptions"
                    }
                })
                .then(res => {
                    this.barcodestyle = res.barcodestyle;
                    this.cxbarcodeprinter = res.cxbarcodeprinter;
                })
                .catch(e => {
                    console.log("error", e);
                })
        },
        //样本类型模板缓存数据加载
        loadvxeSpecimenType(){
            this.xTableSpecimenTypeV = [];
                //获取弹窗信息
            this.localName = 'SMP210_librid_'+this.selLibrid;
            let SmpSpecimenType = this.$tool.getLocalConfig(this.localName);
            if (SmpSpecimenType) {
            //勾选的行数添加到 vxe-table样本类型行
            this.xTableSpecimenTypeV =SmpSpecimenType;
            }
        },
        dataLoad()
        {
            this.InitPatientInfo();
            this.InitsmpDetail();
            this.Initsample();
        },
        //样本登记对象初始化
        InitPatientInfo()
        {
            //样本登记主表对象
            this.PatientInfo ={smp_registerid:null, librid:this.sellibrid, smp_registerdate:this.selectdate,smp_registerno:this.specno,pat_sourcetype:'', originbarcode:'', pat_no:null, pat_cardno:'',
             pat_name:'', pat_sex:'',pat_sexname:'', pat_birth:'', pat_agestr:'',pat_agestr:'', pat_typecode:'',pat_typecodename:'', pat_idcardno:'', smp_registeruser:'',status:'', pat_diag:'', pat_height:'', weight:'', abo_bldtype:'',
             rh_bldtype :'', req_deptno:'',req_deptnoname:'', pat_class:'', hospitalname:'', sourcecode:'', familyornot:'', pathology:'', pathology1:'', pathology2:'', pathology3:'',
              tumorsize:'', tumornumber:'', lymphanumber:'', istransfer:'', tnm:'', isoperation:'', postoperativedays:'', operationdate:'', smpdate:'', remarks:'', pat_phone:'',
              pat_address :'', pat_nation:'', passagecnt:'',strains :'', strainsproperty:'', pat_ageyear:'', antivirus:'', medicine:'', takemeddate:'',cellbatchno :'', passagenum:'',
               cellclass:'',celllevel :'',cellqcflag :'',diseases :'',reserve1 :'', reserve2:'', reserve3:'', reserve4:'', reserve5:'', reserve6:'', reserve7:'',
               reserve8:'',reserve9 :'', reserve10:''};

            this.InitOldPatientInfo();

        },
        //样本登记对象初始化
        InitOldPatientInfo()
        {
             //样本登记主表Old对象
            this.OldPatientInfo ={smp_registerid:null, librid:this.sellibrid, smp_registerdate:this.selectdate,smp_registerno:this.specno,pat_sourcetype:'', originbarcode:'', pat_no:null, pat_cardno:'',
             pat_name:'', pat_sex:'',pat_sexname:'', pat_birth:'', pat_agestr:'',pat_agestr:'', pat_typecode:'',pat_typecodename:'', pat_idcardno:'', smp_registeruser:'',status:'', pat_diag:'', pat_height:'', weight:'', abo_bldtype:'',
             rh_bldtype :'', req_deptno:'',req_deptnoname:'', pat_class:'', hospitalname:'', sourcecode:'', familyornot:'', pathology:'', pathology1:'', pathology2:'', pathology3:'',
              tumorsize:'', tumornumber:'', lymphanumber:'', istransfer:'', tnm:'', isoperation:'', postoperativedays:'', operationdate:'', smpdate:'', remarks:'', pat_phone:'',
              pat_address :'', pat_nation:'', passagecnt:'',strains :'', strainsproperty:'', pat_ageyear:'', antivirus:'', medicine:'', takemeddate:'',cellbatchno :'', passagenum:'',
               cellclass:'',celllevel :'',cellqcflag :'',diseases :'',reserve1 :'', reserve2:'', reserve3:'', reserve4:'', reserve5:'', reserve6:'', reserve7:'',
               reserve8:'',reserve9 :'', reserve10:''};

        },
        //样本登记明细表初始化
        InitsmpDetail()
        {
             //样本登记信息明细表对象
            this.smpDetailObj ={
                smp_regdetailid:''/*标本登记明细ID*/,smp_registerid:''/*标本登记ID*/,smp_type:''/*标本类型*/,smp_number:''/*份数*/,smp_quantity:''/*标本量*/,smp_unit:''/*单位*/,isbarcodeprint:'0'/*是否打印过条码*/
            };
        },
        //样本库信息表对象初始化
        Initsample()
        {
            //样本库信息表对象
            this.sampleObj ={
                smp_sampleid:''/*标本id*/,smp_registerid:''/*标本登记id(科研样本取自smp_registerid,检验留样标本取自req_master的req_id)*/,smp_registerdate:''/*登记日期(科研样本从标本登记主表带过来的,检验留样标本为首次读取日期)*/,smp_registerno:''/*标本号(科研样本从标本登记主表带过来的，检验留样标本为空字串)*/,smp_type:''/*标本类型*/,smp_quantity:''/*标本量*/,smp_unit:''/*单位(字典表)*/,smp_barcode:''/*条码号*/,smp_status:''/*状态(用来记录登记、在库、借出、完成等状态)*/,
                quantitystatus:''/*标本量状态(1正常，2少量)*/,smp_locationid:''/*标本位置横坐标*/,indate:''/*最后入库日期*/,inuser:''/*入库人*/,lenddate:''/*最后借出日期*/,lenduser:''/*借出人*/,finishdate:''/*完成日期*/,finishuser:''/*完成人*/,outdate:''/*抛弃日期*/,
                outuser:''/*抛弃人*/,lendtime:''/*借出次数*/,smp_comments:''/*标本备注*/,smp_part:''/*采集部位*/,preoutdate:''/*预销毁日期*/,sourcetype:''/*样本来源*/,storerequire:''/*标本存放要求*/,maxtemp:''/*存放最高温度*/,mintemp:''/*存放最低温度*/,
                bottletype:''/*存储容器类型*/,createdt:''/*创建时间*/,createuser:''/*创建人*/
            };
        },

        //样本登记表 状态字段显示
        registerStatusDisplay({cellValue}, row, rowIndex, column, columnIndex)
        {

            // [{label: '登记', value: '10'},{label: '打印', value: '20'},{label: '入库', value: '30'},{label: '使用', value: '40'},{label: '作废', value: '90'}]
            return cellValue === '10' ? '登记' : cellValue === '20' ? '打印': cellValue === '30' ? '入库': cellValue === '40' ? '使用': cellValue === '90' ? '作废' : ''
        },
        //样本打印信息 状态字段显示
        sampleStatusDisplay({cellValue}, row, rowIndex, column, columnIndex)
        {

            // [{label: '登记', value: '10'},{label: '打印', value: '20'},{label: '入库', value: '30'},{label: '使用', value: '40'},{label: '作废', value: '90'}]
            return cellValue === '10' ? '登记' : cellValue === '20' ? '打印': cellValue === '30' ? '在库': cellValue === '40' ? '借出':cellValue === '50' ? '完成': cellValue === '90' ? '作废' : ''
        },
        //样本登记表 是否显示
        CheckStatusDisplay({cellValue}, row, rowIndex, column, columnIndex)
        {
            return cellValue === '1' ? '是' :cellValue === '0'? '否':'';
        },
        formatFun({ cellValue, column, row }) {
            if (["pat_sourcetype"].includes(column.property)) {
                try {
                    if(cellValue ==="1"){
                        return "本院"
                    }else if(cellValue === "2"){
                        return "外院"
                    }else{
                        return cellValue
                    }
                } catch {}
            }else if(["sourcetype"].includes(column.property)){
                try {
                    if(cellValue ==="0"){
                        return "科研"
                    }else if(cellValue === "1"){
                        return "检验"
                    }else{
                        return cellValue
                    }
                } catch {}

            // } else if (
            //     ["cntname"].includes(column.property) &&
            //     this.searchobj.bypat == "1"
            // ) {
            //     try {
            //         let deptname = this.deptOption.find(
            //             (m) => m.data == cellValue
            //         )
            //         if (deptname != undefined && deptname != null) {
            //             return deptname.display
            //         } else {
            //             return cellValue
            //         }
            //     } catch {}
            // } else if (
            //     ["cntname"].includes(column.property) &&
            //     this.searchobj.bypat == "2"
            // ) {
            //     try {
            //         let hospname = this.hospOption.find(
            //             (m) => m.value == cellValue
            //         )
            //         if (hospname != undefined && hospname != null) {
            //             return hospname.label
            //         } else {
            //             return cellValue
            //         }
            //     } catch {}
            } else {
                return cellValue
            }
        },
        //标本库列表下拉框初始化
        ddlSmp_Library() {
            this.$tool
                .request({
                    url: "SMP/SMP1/SMP130",
                    method: "post",
                    data: {
                        action: "q_smp_library",
                        islibrtype: "",
                        showstatus: "",
                    },
                })
                .then((res) => {
                    //不登记细菌库  librtype !=10
                    if(res.length>0)
                    {
                        for (let index = 0; index < res.length; index++) {
                            var element = res[index];
                            if (element.librtype === 10) {
                                res.splice(index,1);
                                index--;
                            }
                        }
                        this.selSmpLibrary_Options = res;
                        this.selLibrid = this.selSmpLibrary_Options[0].librid;
                        this.QueryCol();
                        this.$nextTick(() => {
                        this.loadSpecimenTypeDialog();//初始化样本类型弹窗
                        });
                    }

                });
        },
        //加载样本类型弹窗
        async loadSpecimenTypeDialog()
        {
                if (this.selLibrid) {
                    this.$tool.request({
                    url: "SMP/SMP1/SMP110",
                    method: "post",
                    data: {
                        action: "smp_smptype_query",
                        keystr: this.txtSearch,
                        librid: this.selLibrid,
                    }
                })
                .then((res)=>{
                    //绑定数据
                    this.fulldata = res.RData;
                    console.log(this.fulldata);
                    //重新绑定grid控件
                    this.setcol();
                    //表格过滤
                    this.filterdata();
                })
                .catch((e)=>{
                this.$message.warning(e)
                this.lLoading = false
                })
            }

        },
        //查询DDL公用后台方法
        Queryddl(colcode, type) {
             if (!colcode) colcode = this.popdatatype;
            if (this.InputCodeArr.filter(item => item.key == colcode).length == 0) {
               this.$tool
                    .request({
                        url: "ucent/ddl",
                        method: "post",
                        data: {
                            action: colcode,
                            librid: this.selLibrid
                        }
                    })
                    .then(res => {
                        if (!res.hasOwnProperty("errcode")) {
                            this.InputCodeArr.push({ key: this.popdatatype, list: res });
                            if (type) {
                                var selitem = this.tableDataColumn.find((item) => item.col_code == colcode.replace("SMP210_", ""));
                                if (selitem && res) {
                                    var valuename = res.Data.find((item) => item.hidkey == selitem.default_val);
                                    if (valuename) {selitem.default_val = valuename.hidname;
                                        this.PatientInfo[colcode.replace("SMP210_", "")] = valuename.hidkey;
                                        this.PatientInfo[colcode.replace("SMP210_", "") + "name"] = selitem.default_val;
                                    }
                                    else selitem.default_val = selitem.default_val;
                                }
                            }
                        }
                    });
            }
            else {
                if (type) {
                    var data = this.InputCodeArr.find((item) => item.key == colcode);
                    var selitem = this.tableDataColumn.find((item) => item.col_code == colcode.replace("LIS3_", ""));
                    if (selitem && data) {
                        var valuename = data.list.Data.find((item) => item.hidkey == selitem.default_val);
                        if (valuename) {selitem.default_val = valuename.hidname;
                                    this.PatientInfo[colcode.replace("SMP210_", "")] = valuename.hidkey;
                                    this.PatientInfo[colcode.replace("SMP210_", "") + "name"] = selitem.default_val;
                                }
                        else selitem.default_valname = selitem.default_val;
                    }
                }
            }
        },
        //查询DDL公用后台方法
        ClickQueryddl(value, type) {
            if (this.InputCodeArr.filter(item => item.key == this.popdatatype).length == 0&&value) {
               this.$tool
                    .request({
                        url: "ucent/ddl",
                        method: "post",
                        data: {
                            action: this.popdatatype,
                            librid: this.selLibrid
                        }
                    })
                    .then(res => {
                        if (!res.hasOwnProperty("errcode")) {
                            this.InputCodeArr.push({ key: this.popdatatype, list: res });


                            console.log(this.InputCodeArr);
                            console.log(this.$refs[type]);
                            if (type == "specno") {
                                this.$refs.specno.select();
                            } else if (type == "lab_advice") {
                                this.QueryAdvice();
                                this.$refs[type][0].select();
                            } else {
                                if (type.toUpperCase().indexOf("_DT") == -1 && type.toUpperCase().indexOf("_DATE") == -1) {
                                    this.$refs[type][0].select();
                                } else {
                                    this.$refs[type][0].focus();
                                }
                            }
                        if (this.Options.inputasreportuser == "0" && type != "rechk_user" && type != "report_user")
                        {
                        this.PatientInfo.report_username = this.exactusernamereport;
                        this.PatientInfo.report_user = this.exactusernoreport;
                        }
                        switch (type) {
                            case "pat_agestr":
                                var reg = new RegExp("\\d{1,}(y|Y|岁|年){0,}\\d{0,}(m|M|月){0,}\\d{0,}(d|D|日){0,}\\d{0,}(h|H|小时){0,}\\d{0,}(f|F|分钟){0,}", "gi");
                                var regd = new RegExp("^\\d{1,}$", "gi");
                                var regda = new RegExp("\\d{1,}", "gi");
                                if (value.match(regd)) {
                                    this.PatientInfo[type] = value + "岁";
                                    this.PatientInfo["pat_ageyear"] = value - 0;
                                } else if (value.match(reg)) {
                                    this.PatientInfo[type] =
                                        value
                                            .replace("y", "岁")
                                            .replace("年", "岁")
                                            .replace("Y", "岁")
                                            .replace("m", "月")
                                            .replace("M", "月")
                                            .replace("d", "日")
                                            .replace("D", "日")
                                            .replace("h", "小时")
                                            .replace("H", "小时")
                                            .replace("f", "分钟")
                                            .replace("F", "分钟") + "";
                                    this.PatientInfo.pat_ageyear = this.ageTransform(this.PatientInfo.pat_agestr);
                                } else {
                                    this.$confirm("无效的病人年龄!", "提示", {
                                        confirmButtonText: "确定",
                                        cancelButtonText: "取消",
                                        focusCancelButton: false,
                                        closeOnClickModal: false,
                                        type: "warning"
                                    })
                                        .then(() => {})
                                        .catch(() => {});
                                }
                                break;
                            case "lab_advice":
                                var list = this.InputCodeArr.filter(item => item.key == this.popdatatype);
                                if (list.length > 0) {
                                    var row = list[0].list.Data.filter(item => (item.txtinfo + "").toUpperCase() == (value + "").toUpperCase() || (item.txttitle + "").toUpperCase() == (value + "").toUpperCase() || (item.inputcode + "").toUpperCase() == (value + "").toUpperCase());
                                    if (row.length > 0) {
                                        this.PatientInfo[type] = row[0].txtinfo;
                                    }
                                }
                                break;
                            default:
                                let selitem = this.tableDataColumn.find(item => item.col_code == type);
                                if (selitem && selitem.noedit) {
                                    return;
                                }
                                if (value.trim()) {
                                    var list = this.InputCodeArr.filter(item => item.key == this.popdatatype);
                                    if (list.length > 0) {
                                        var row = list[0].list.Data.filter(item => (item.inputcode + "").toUpperCase() == (value + "").toUpperCase() || (item.hidkey + "").toUpperCase() == (value + "").toUpperCase());
                                        if (row.length > 0) {
                                            if (type == "rechk_user" || type == "report_user") {
                                                this.usercode = row[0].hidkey;
                                                this.username = row[0].hidname;
                                                this.userpwd = "";
                                                this.dialogLoginVisible = true;
                                                this.$nextTick(() => {
                                                    this.$refs.loginpwd.focus();
                                                });
                                            } else {
                                                this.PatientInfo[type + "name"] = row[0].hidname;
                                                this.PatientInfo[type] = row[0].hidkey;
                                            }
                                        } else {
                                            if (type == "pat_sex" || type == "pat_typecode" || type == "specimen_code" || type == "rechk_user" || type == "report_user") {
                                                this.dialogTableVisible = true;
                                            } else {
                                                var re = new RegExp("[\\u4e00-\\u9fa5]", "gi");
                                                if (!re.test(value)) {
                                                    this.dialogTableVisible = true;
                                                }
                                            }
                                        }
                                    }
                                } else {
                                    this.PatientInfo[type] = "";
                                }
                                break;
                        }
                        }



                    });
            }
        },
        //加载valuetype ==3 的下拉框后台设置属性
        QueryDropdownLoad(colcode) {

        },
        QueryCol(init) {
            // console.log("🚀 ~ file: SMP210.vue ~ line 285 ~ QueryCol ~ this.selLibrid", this.selLibrid);
            this.$tool
                .request({
                    url: "SMP/SMP2/SMP210",
                    method: "post",
                    data: {
                        action: "q_smp210_input_col",
                        librid: this.selLibrid,
                    },
                })
                .then((res) => {
                    console.log("res", res);
                    if (res) {
                        this.tableDataColumn = res;
                        if (init === 1) {
                            return
                        }

                        this.ColData = [];
                        // this.PatientInfo = {};
                        this.dataLoad();
                        this.ColTotalData = [];
                        res = res.filter((item) => item.visibled == true); //可显示
                        //过滤错误字段
                        res = res.filter(item => item.col_code != "emer_flag");
                        console.log("高", this.$refs.xTableDiv.offsetHeight);
                        //查询样本库登记---初始化输入字段表valuetype为3的下拉框Option绑定的数据
                        this.Load_DropdownAll(res);
                        //更新UI (初始化登记控件排版)
                        this.HisUI(res);
                        //打印ColTotalData（HIS样本库登记绑定信息）
                        // console.log("🚀 ColTotalData结果", this.ColTotalData);



                        this.$nextTick(() => {
                            //查询样本登记表数据
                            this.smpRegisterQuery();

                            //给PatientInfo对象添加属性
                            // if (this.selSmpLibrary_Options.length>0) {
                            // this.librid = this.$refs.selLibrid.value; //this.librid 弹框绑定变量
                            //     this.PatientInfo['librID'] =this.selSmpLibrary_Options[0].librid;
                            //     this.$refs.barcode[0].focus();
                            //     if (this.$refs.barcode && this.$refs.barcode[0]) {
                            //         this.$refs.barcode[0].select();
                            //     }
                            // }

                        });
                    }
                })
                .catch((error) => {
                    this.$message.error("错误1:" + error);
                    console.log("error", error);
                });
        },
        LibridChange() {
            this.specno = '1'
            // this.PatientInfo['']
            // console.log("🚀 ~ file: SMP210.vue ~ line 320 ~ LibridChange ~ this.selLibrid", this.selLibrid);
            this.QueryCol();
            // this.$nextTick(() => {
            // this.loadSpecimenTypeDialog();//初始化样本类型弹窗
            // this.loadvxeSpecimenType();
            // });

        },
        //上一个、下一个
        //async BtnPreviousNext(event,serialNo)
         BtnPreviousNext(event,serialNo)
        {
            //清空条码信息勾选
            this.SampleIdKeys = [];
            //根据序号匹配登记信息
            /* 1.如果匹配到登记信息,选中登记信息行并且把登记信息数据保存在patientinfo,
             如果patientinfo与this.RegisterTableData的Row(选中的登记行)信息不一致,则需要发送修改请求
             2.如果没有匹配到登记信息,则取消选中行,如果patientinfo有输入值则新增,并且清空patientinfo */
            let tempRegisterTable = this.RegisterTableData;
            let Rowcount =tempRegisterTable.length;
            let edit = false;
            if (Rowcount==0&&this.PatientInfo['pat_no']) {
                // edit = true
                this.btnSave(true);
            }
            for (let previousIndex = 0; previousIndex <Rowcount ; previousIndex++) {
                let element = tempRegisterTable[previousIndex];
               //修改登记信息
               if (element.smp_registerno==this.specno) {
                   //edit = 'edit';
                   //校验patientinfo 与 row数据不一致 则修改
                   let canEdit = false;
                    for(var field in this.PatientInfo)
                    {
                        if (field == 'smp_registerdate'||field == 'smp_registerno')
                        continue;
                        if(typeof(field) == 'undefined')
                        break;
                        if (field) {
                            if (this.PatientInfo.hasOwnProperty(field)) {
                            if (!deepEqual(this.PatientInfo[field],this.OldPatientInfo[field])) {
                                canEdit=true;
                                edit =true;
                                break;
                            }
                        }
                      }

                    }
                   //调用save
                   if(canEdit)
                   this.btnSave(true);
                   break;
               }
               //如果不存在登记信息,且输入病人号则新增
               if (previousIndex==tempRegisterTable.length-1) {
                   let canAdd = false;
                    if(!this.PatientInfo['pat_no'])
                    {
                        continue;
                    }
                    for(var field in this.PatientInfo)
                    {
                        if (field == 'smp_registerdate'||field == 'smp_registerno')
                        continue;
                        if(typeof(field) == 'undefined')
                        break;
                        if (field) {
                            if (this.PatientInfo.hasOwnProperty(field)) {
                                if (this.PatientInfo[field]) {
                                    canAdd=true;
                                    edit = true;
                                    break;
                                }
                            }
                        }
                    }
                   //新增
                   if(canAdd){
                        this.btnSave(true);
                   }
               }
            }
            //每次上次步下一步新增明细
            if (!edit) {
            this.savedetail(false);
            }

            /**正则(1.获取字符串用于拼接 2.获取number用与计数) */
            let regexNumber = new RegExp('\\d+$');//匹配结尾为数字:\d+$      匹配结尾不为数字: ^\S+[^(\d+$)]
            //前缀字符串
            let strPrefix = this.specno;
            let valSpeNo = this.specno;
            //结尾数字
            let number = parseInt(regexNumber.exec(valSpeNo));
            let subIdx;
            if(number)
                subIdx = strPrefix.lastIndexOf(number);
            else
                subIdx = strPrefix.length;

            //无规律序号
            if(subIdx<0)
            {
                //序号默认为1

            }
            else
            {
                //
                strPrefix = strPrefix.substring(0,subIdx);
            }

            // number = parseInt(this.specno);

            if (number<1) {
                this.specno =1;
                }

            //上一个
            if (serialNo=='previous') {
               if (number>1)
               number -=1;
            }
            //下一个
            else if (serialNo=='next') {
                number+=1;
            }
            if(number>0)
            this.specno =strPrefix + number;
            else
            this.specno =strPrefix;

            if (!this.specno) {
                this.specno = 1;
            }

            //移动后的登记序号
            //调用一遍查询
            if (!edit) {
                this.smpRegisterQuery();
            }

        },

        //查询样本登记信息
        //async smpRegisterQuery() {
        async smpRegisterQuery(operationMode) {

            console.log('smpRegisterQuery()当前时间: ',new Date());
            if (operationMode=='changeDate') {
                this.specno = '1'
            }
            // let tempDateTime =
            this.$tool
                .request({
                    url: "SMP/SMP2/SMP210",
                    method: "post",
                    data: {
                        action: "smp_register_query",
                        keystr: this.txtSearch,
                        regdate:this.selectdate instanceof Date?formatDate(this.selectdate):this.selectdate,
                        librid: this.selLibrid,
                        specno:this.specno,
                        operationMode:operationMode,
                    },
                })
                 .then((res) => {
                    if (res) {
                        this.RegisterTableData = res.RegisterRData.Data;
                        if (this.RegisterTableData.length>0) {
                            let tempSpecno =this.specno;
                            let tempData = this.RegisterTableData;

                            for (let index = 0; index < tempData.length; index++) {
                                let element = tempData[index];
                                //已存在登记信息
                                if (element.smp_registerno==tempSpecno) {
                                    //选中当前行
                                    this.$nextTick(()=>{
                                        var row = this.$refs.xTable.tableFullData.find(item => item.smp_registerno == tempSpecno);
                                        if (row) {
                                            this.$refs.xTable.setCurrentRow(this.RegisterTableData[index])
                                            this.$refs.xTable.scrollToRow(row);
                                        }
                                        //明细查询
                                        this.RegisterRowClick(this.RegisterTableData[index]['smp_registerid'],'',res);
                                    })
                                    break;
                                }
                                else if (index ==tempData.length-1) {

                                    //默认选中最后一行
                                    this.$nextTick(()=>{
                                        if (operationMode=='changeDate') {
                                            var row = this.$refs.xTable.tableFullData.find(item => item.smp_registerno == res.RegisterRData.Data[0]['smp_registerno']);
                                            if (row) {
                                                this.$refs.xTable.setCurrentRow(this.RegisterTableData[0])
                                                this.$refs.xTable.scrollToRow(row);
                                                //明细查询
                                                this.RegisterRowClick(row['smp_registerid'],'',res);
                                            }
                                            else
                                            {
                                                //清空xTable行
                                                this.InitPatientInfo();
                                                //加载默认样本类型模板
                                                this.initSmpDetailRowDisplay();
                                                //清空打印信息
                                                this.SampleTableData =[];
                                            }
                                        }
                                        else
                                        {
                                             //清空xTable行
                                                this.InitPatientInfo();
                                                //加载默认样本类型模板
                                                this.initSmpDetailRowDisplay();
                                                //清空打印信息
                                                this.SampleTableData =[];
                                        }
                                    })
                                }
                            }
                        }
                        else
                        {
                            //清空xTable行
                            this.InitPatientInfo();
                            //加载默认样本类型模板
                            this.initSmpDetailRowDisplay();
                            //清空打印信息
                            this.SampleTableData =[];
                        }
                        //刷新默认值
                        this.referenceDefault();
                    }
                })
                .catch((error) => {
                    this.$message.error("错误1:" + error);
                    console.log("error", error);
                });

                //this.referenceDefault();
        },

        //线程函数打印
        taskPrint()
        {
            /**保存明细 */
             let tempsmp_registerid =this.OldPatientInfo['smp_registerid'];
             if (tempsmp_registerid) {
                this.DetailTableData.forEach((item) => {
                    if (!item['smp_registerid']) {
                        this.$refs.xTableDetail.insert({ smp_registerid: item.smp_regdetailid,
                        smp_registerid: item.smp_registerid, smp_type: item.smp_type,
                        smp_number: item.smp_number, smp_quantity: item.smp_quantity,
                        smp_unit: item.smp_unit , isbarcodeprint: item.isbarcodeprint
                        })
                    }
                });
                    console.log('🚀我是getRecordset()',this.$refs.xTableDetail.getRecordset());
                    let record =this.$refs.xTableDetail.getRecordset();
                if (record.insertRecords.length>0) {
                    this.$tool
                    .request({
                        url: "SMP/SMP2/SMP210",
                        method: "post",
                        data: {
                            action: "smp_register_save",
                            registerinfo: this.OldPatientInfo,
                            details:this.DetailTableData.length===0?null:record
                        },
                    })
                    .then((response) => {
                        //
                        console.log('保存的信息',response);

                        //成功
                        if (response.errcode == "1") {
                            //查询打印明细
                            this.QueryDetailPrint();
                        }
                        else {
                                this.$message({
                                    message:"保存失败！\r" + response.errmsg,
                                    type: "warning",
                                })
                                return response.errmsg;
                            }

                    })
                    .catch((e) => {
                        console.log("error", e);
                        return e;
                    });
                }
            }







        },
         //查询登记明细与样本条码信息
        smpDetailQuery(RegisterID)
        {
            this.DetailLoading = true;
            if (RegisterID) {
                 this.$tool
                .request({
                     url: "SMP/SMP2/SMP210",
                    method: "post",
                    data: {
                        action: "smp_register_query_byid",
                        smp_registerid: RegisterID,
                        librid: this.selLibrid,
                         },
                })
                 .then((res) => {
                     let tempSampleData;
                      //条码样本信息
                     if (res.RSample&&this.OldPatientInfo['smp_registerid']) {
                         if(res.RSample.Data)
                         {
                            this.SampleTableData = res.RSample.Data;
                            tempSampleData = res.RSample.Data;
                         }
                     }
                     //已有明细
                     if (res.RDetail&&this.OldPatientInfo['smp_registerid']) {
                         if (res.RDetail.Data) {
                                //显示是否勾选打印明细(不是"已打印")
                                if (tempSampleData) {
                                    for (let index = 0; index < res.RDetail.Data.length; index++) {
                                         let rowDetail =  res.RDetail.Data[index];
                                        if (rowDetail.hasOwnProperty('isbarcodeprint')) {
                                            if (res.RDetail.Data[index]['isbarcodeprint'] =='0') {
                                                res.RDetail.Data[index]['ischk'] ='1';
                                            }
                                            else
                                            {
                                                let sumPrint = 0;
                                                for (let idx = 0; idx < tempSampleData.length; idx++) {
                                                    const rowSmp = tempSampleData[idx];
                                                    if (rowSmp["smp_registerid"]==rowDetail["smp_registerid"]&&rowSmp["smp_type"]==rowDetail["smp_type"]) {
                                                        sumPrint++;
                                                        if (sumPrint==rowDetail["smp_number"]) {
                                                            break;
                                                        }
                                                    }
                                                }
                                                res.RDetail.Data[index]["smp_sumprint"] = sumPrint;
                                            }
                                        }
                                }
                            }
                                this.DetailTableData= res.RDetail.Data;
                                this.DetailTableData.sort((a, b) => {
                                let seq1 = a.seq
                                let seq2 = b.seq
                                return a.seq - b.seq
                            })
                         }
                     }
                     //默认明细
                     else{
                         this.initSmpDetailRowDisplay();
                     }

                })
                .catch((error) => {
                    //默认明细
                    this.$message.error("错误1:" + error);
                    console.log("error", error);
                });
            }
        },


        //样本类型缓存对象本地保存
        saveLocalSampleType(){
            $tool.setLocalConfig();
        },

        BtnSort() {},
        BtnPrint() {
            var sql = "select top 1 * from req_master_all_name";
            sql = btoa(encodeURIComponent(sql));
            jsObj.PrintCustomReport("5002", sql, "lis", "req_master", ""); //*
        },
        BtnExport() {},
        async InitPageDate() {
            try {
                const res = await this.$tool.request({
                    url: "SMP/SMP2/SMP210",
                    method: "post",
                    data: {
                        action: "initOption",
                    },
                });
                this.logTableData = res.Data;
            } catch (e) {
                this.$message.warning(e);
            }
        },
        CurrentChangeEvent({ row, rowIndex }) {
            //this.tempIndex = rowIndex;
        },
        //Row排序
        // changeTableSort({column,property,order})
        // {
        //     console.log(column);
        //     console.log(property);
        //     console.log(order);
        // },
        cellClassName({ columnIndex, row }) {
            if (columnIndex == "0" || columnIndex == "1") {
                if (row.flag == "1") {
                    //不能再次选择
                    return "col-orange";
                } else {
                    //新增的数据
                    return "";
                }
            } else {
                return "";
            }
        },
        //样本登记信息删除
         btnSmpRegisterDel(){
              this.$confirm("您确定要删除吗？", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
            })
                .then(() => {
            //1.获取需要删除的样本库登记表主键ID
            let tempdata = this.$refs.xTable.getCurrentRow();
            //调用后台删除方法
            if (tempdata.smp_registerid) {

                this.$nextTick(() => {
                //调用后台删除样本库登记信息方法
                this.$tool.request(
                    {
                    url: "SMP/SMP2/SMP210",
                    method: "post",
                    data: {
                        action: "smp_register_delete",
                        smp_registerid: tempdata.smp_registerid,
                        // details:this.PatientInfo
                          },
                    }             )
                .then((res)=>{
                    console.log('删除成功:',res);
                    //删除后更新UI
                    this.$refs.xTable.remove(tempdata);
                    //移除this.RegisterTableData的数据(删除对象)
                    let tempRegisterTableData = this.RegisterTableData;
                    for (let index = 0; index < tempRegisterTableData.length; index++) {
                        const elementDel = tempRegisterTableData[index];
                        if (elementDel) {
                            if(elementDel['smp_registerid']&&tempdata.smp_registerid)
                            {
                                if (elementDel['smp_registerid']==tempdata.smp_registerid) {
                                     this.RegisterTableData.splice(index,1);
                                     break;
                                }
                            }
                        }
                    }
                    this.InitPatientInfo();
                    this.DetailTableData=[];
                    this.SampleTableData=[];
                    //刷新样本类型缓存
                    this.initSmpDetailRowDisplay();
                    this.referenceDefault();
                    })
                .catch((e)=>{
                    console.log('删除失败:',e);

                    })
                });
            }
                })
                .catch((e) => {});

            //this.referenceDefault();
        },
        //保存
        //async btnSave(isquery) {
        btnSave(isquery) {
            try {
                 //let date = this.$refs.xTable.getTableData().fullData;

                let strValid = this.btnSavePrepare();
                if (strValid=='0')
                    return;

                //将Json Post到后台入库
                this.$tool
                .request({
                    url: "SMP/SMP2/SMP210",
                    method: "post",
                    data: {
                        action: "smp_register_save",
                        registerinfo: this.PatientInfo,
                        details:this.DetailTableData.length===0?null:this.$refs.xTableDetail.getRecordset()
                    },
                })
                .then((response) => {
                    //
                    console.log('保存的信息是',response);


                     if (response.errcode == "1") {
                            this.$message({
                                message: "登记成功!",
                                type: "success",
                            })
                        if (isquery) {
                        //查询
                        this.smpRegisterQuery();
                        }
                    } else {
                            this.$message({
                                message:"保存失败！\r" + response.obj +"\r插入登记ID:"+response.keyid,
                                type: "warning",
                            })
                        //查询
                        //this.smpRegisterQuery();
                        }
                })
                .catch((e) => {
                    console.log("方法btnSave()出错:", e);
                });

            }
            catch (e) {
                this.$alert(e);
            }
        },
        //保存前的准备
        btnSavePrepare()
        {
            try {
                let strValid = '';
            this.popoverSaveContent = '';
            //获取样本登记信息到绑定的数组对象上
            if (this.ColTotalData) {

                //样本库ID校验
                if (!this.selLibrid) {
                    this.popoverSaveContent+="请去<<样本库字典>>页面添加'样本库'! \n";
                }


                //输入字段校验
                for(let fieldstr in this.PatientInfo)
                {
                    if (fieldstr=='librid') {
                        this.PatientInfo['librid'] = this.selLibrid;
                    }
                    //登记日期校验
                    if (fieldstr=='smp_registerdate') {
                        if (!this.PatientInfo['smp_registerdate']) {
                        this.popoverSaveContent+="请输入登记日期 \n";
                        }
                    }
                    //序号校验
                    if (fieldstr=='smp_registerno') {
                        this.PatientInfo['smp_registerno'] = this.specno;
                        if (!this.PatientInfo['smp_registerno']) {
                        this.popoverSaveContent+="请输入序号 \n";
                        }
                    }
                    //病人号校验
                    if (fieldstr=='pat_no') {
                        if (!this.PatientInfo['pat_no']) {
                        this.popoverSaveContent+="请输入病人号 \n";
                        }
                    }
                }
                //校验不通过
                    if (this.popoverSaveContent!='') {
                        this.PatientInfo['librid'] = "";
                        this.$message({
                                    message: this.popoverSaveContent,
                                    type: "warning",
                                })
                        this.popoverSaveContent=''
                        strValid = '0';
                        return strValid;
                    }
            }
            //
            if (this.PatientInfo!=""&&this.PatientInfo!=null&&this.PatientInfo!='undefined') {
                console.log('btnSavePrepare()编辑信息:',this.PatientInfo);
                    //修改校验
                    if (this.OldPatientInfo['smp_registerno']) {
                    //如果是修改消息,则不能修改序号
                        if (this.PatientInfo['smp_registerno']!==this.OldPatientInfo['smp_registerno'])
                        {
                            strValid = '0';
                            return strValid;
                        }
                    }
                    //给新增明细赋值登记ID
                    if (this.OldPatientInfo['smp_registerid']) {
                        for (let index = 0; index < this.DetailTableData.length; index++) {
                            if (!this.DetailTableData[index]['smp_registerid']) {
                                this.DetailTableData[index]['smp_registerid'] =this.OldPatientInfo['smp_registerid'];
                            }
                        }
                    }
                    //登记ID
                    // let tempRegisterID;
                    // let tmepdata = this.DetailTableData;
                    //     if (tmepdata instanceof Array) {
                    //         tmepdata.forEach(item=> {
                    //             tempRegisterID[item.name] = item.ct
                    //         })
                    //     }
                    //     else
                    //         tempRegisterID =this.DetailTableData;
                    let dispalyDetail = [];
                    //tableinsert
                    this.DetailTableData.forEach((item) => {
                        if (!item['smp_regdetailid']) {
                            this.$refs.xTableDetail.insert({ischk:item.ischk, smp_regdetailid: item.smp_regdetailid,
                            smp_registerid: item.smp_registerid, smp_type: item.smp_type,specimen_name:item.specimen_name,
                            smp_number: item.smp_number, smp_quantity: item.smp_quantity, seq:item.seq,
                            smp_unit: item.smp_unit , isbarcodeprint: item.isbarcodeprint
                            }).then(({ row }) => {
                                this.$refs.xTableDetail.setCurrentRow(row);
                                this.$refs.xTableDetail.scrollToRow(row);
                            });
                        }
                        else
                            dispalyDetail.push(item);  //已存在数据显示缓存
                    });


                    this.DetailTableData =dispalyDetail.concat(this.$refs.xTableDetail.getInsertRecords());
                    this.DetailTableData.sort((a, b) => {
                    let seq1 = a.seq
                    let seq2 = b.seq
                    return a.seq - b.seq
                    })

            }
            else
                strValid = '0';

                return strValid;
            }
            catch (error) {
                this.$alert('btnSavePrepare()方法出错:',error);
            }

        },

        //保存
        //async btnSave(isquery) {
        btnPrintSave(isquery) {
            try {
                 //let date = this.$refs.xTable.getTableData().fullData;


                let strValid = this.btnSavePrepare();
                if (strValid=='0')
                    return;

                //将Json Post到后台入库
                this.$tool
                .request({
                    url: "SMP/SMP2/SMP210",
                    method: "post",
                    data: {
                        action: "smp_register_save",
                        registerinfo: this.PatientInfo,
                        details:this.DetailTableData.length===0?null:this.$refs.xTableDetail.getRecordset()
                    },
                })
                .then((response) => {
                    //
                    console.log('保存的信息',response);


                     if (response.errcode == "1") {
                            this.$message({
                                message: "操作成功！新增明细!",
                                type: "success",
                            })
                        if (isquery) {
                            //查询
                            this.smpRegisterQueryPromise();
                        }
                    } else {
                            this.$message({
                                message:"保存失败！\r" + response.obj +"\r插入登记ID:"+response.keyid,
                                type: "warning",
                            })
                        //查询
                        this.smpRegisterQueryPromise();
                        }
                })
                .catch((e) => {
                    console.log("方法btnSave()出错:", e);
                });

            }
            catch (e) {
                this.$alert(e);
            }
        },
        RePrintBarcodes(cData, ptype, i) {
            // if (i >= cData.length) {
            //     return;
            // } else {
            //     let barcode = cData[i].smp_barcode;
            //     // if (cData[i].smp_status != "1" && cData[i].smp_status != "2") {
            //     //     this.$confirm("条码号:" + barcode + "(" + cData[i].req_groupna + ")， 状态是【" + cData[i].req_statname + "】，您是否要继续重打条码?", "提示", {
            //     //         confirmButtonText: "确定",
            //     //         cancelButtonText: "取消",
            //     //         focusCancelButton: true,
            //     //         closeOnClickModal: false,
            //     //         type: "warning"
            //     //     })
            //     //         .then(() => {
            //     //             this.printbarcode(barcode, ptype, "", "1");
            //     //             this.RePrintBarcodes(cData, ptype, i + 1);
            //     //         })
            //     //         .catch(() => {});
            //     // } else {
            //         // this.printbarcode(barcode, ptype, "", "1");
            //         this.StartPrintBarcode(cData);
            //         this.RePrintBarcodes(cData, ptype, i + 1);
            //     //}
            // }
        },

        //打印条码
        btnPrintBarcode(){
        // console.log(this.$refs.xTableSample.getSelectRecords());
            if (typeof(jsObj) != undefined&&typeof(jsObj) !== 'undefined') {
                //获取选中行
                let currentRow = this.$refs.xTable.getCurrentRow();
                let strPrintDetail = '';
                console.log("currentRow：",currentRow);
                if (!currentRow) {
                    //新增
                    strPrintDetail = '1';
                    this.btnPrintSave(true);
                }
                else
                {
                    strPrintDetail = '2';
                    //修改
                    if (currentRow['pat_no']!=this.PatientInfo['pat_no']) {
                        this.$confirm("您确定要修改病人号吗?", {
                        confirmButtonText: "确定",
                        cancelButtonText: "取消",
                        type: "warning",
                        })
                        .then(() => {
                            //this.btnPrintSave(true);
                             this.thePrintDetail();
                        })
                    }
                    else //新增
                    {
                        this.thePrintDetail();
                        //this.btnPrintSave(true);
                    }
                }
                //根据明细打印
                if (strPrintDetail == '') {
                    this.thePrintDetail();
                }
            }
            else
            {
                this.$alert("请使用" + this.$pub.clientname + "", "提示");
            }
        },

        //先查询后打印
         //查询登记明细与样本条码信息
        smpQueryPrint(RegisterID)
        {
            this.DetailLoading = true;
            if (RegisterID) {
                 this.$tool
                .request({
                     url: "SMP/SMP2/SMP210",
                    method: "post",
                    data: {
                        action: "smp_register_query_byid",
                        smp_registerid: RegisterID,
                        librid: this.selLibrid,
                         },
                })
                 .then((res) => {
                     //已有明细
                     if (res.RDetail&&this.OldPatientInfo['smp_registerid']) {
                         for (let index = 0; index < res.RDetail.Data.length; index++) {
                             res.RDetail.Data[index]['ischk'] ='1';
                         }
                            this.DetailTableData= res.RDetail.Data;
                            this.DetailTableData.sort((a, b) => {
                            let seq1 = a.seq
                            let seq2 = b.seq
                            return a.seq - b.seq
                        })
                     }
                     //默认明细
                     else{
                         this.initSmpDetailRowDisplay();
                     }
                     //条码样本信息
                     if (res.RSample&&this.OldPatientInfo['smp_registerid']) {
                         this.SampleTableData = res.RSample.Data;
                        //  this.RePrintBarcodes( res.RSample.Data, "2", 0);
                          //提示
                        this.$message({message: "打印成功！",type: "success",})
                     }
                })
                .catch((error) => {
                    //默认明细
                    this.$message.error("错误1:" + error);
                    console.log("error", error);
                });
            }
        },

        //获取明细信息生成样本信息
        thePrintDetail(){
        //this.$refs.xTableDetail.updateListenter();
        let detail = this.DetailTableData;
        if (detail) {
            let insertDetail =[];
            for (let index = 0; index < detail.length; index++) {
                let element = detail[index];
                if (element['ischk']=='1') {
                    if (!element['smp_regdetailid'])
                        insertDetail.push(element);
                }
            }
            if (insertDetail.length>0) {
                this.taskPrint();
            }
            else
            {
                let printDetail =[];
                for (let index = 0; index < detail.length; index++) {
                    let element = detail[index];
                    if (element['ischk']=='1') {
                        // if (element['isbarcodeprint']=='0')
                            printDetail.push(element);
                    }
                }
                let registerID = this.OldPatientInfo['smp_registerid'];
                //打印样本条码信息
                    if (printDetail.length > 0&& registerID) {
                        //生成条码
                        this.$tool
                        .request({
                            url: "SMP/SMP2/SMP210",
                            method: "post",
                            data: {
                                action: "createbarcode",
                                details: printDetail,
                            },
                        })
                        .then((res) => {
                            console.log(res);
                            let s = 1;
                            if (res.flag=='1') {
                                let tempCheckArr = [];
                                if (res.isCheckSample) {
                                    if (res.isCheckSample.Data) {
                                        for (let index = 0; index < res.isCheckSample.Data.length; index++) {
                                            let element = res.isCheckSample.Data[index];
                                            tempCheckArr.push(element['smp_barcode']);
                                            for (let index2 = 0; index2 < printDetail.length; index2++) {
                                                let element2 = detail[index2];
                                                if (element['smp_type']==element2['smp_type']) {
                                                    //res.isCheckSample.Data[index]['smp_typename'] =element2['specimen_name'];
                                                    res.isCheckSample.Data[index]['specimen_name'] =element2['specimen_name'];
                                                }
                                            }
                                        }
                                    }
                                }

                                this.SampleIdKeys = tempCheckArr;
                                console.log(this.SampleIdKeys);
                                //查询明细
                                this.smpQueryPrint(registerID);
                                if (res.isCheckSample) {
                                    if (res.isCheckSample.Data) {
                                        //此处打印
                                        this.StartPrintBarcode(res.isCheckSample.Data);
                                    }
                                }
                                //打印成功
                                //this.$message({message: "打印成功！",type: "success",})
                            }
                            else
                            {
                                this.$message.error("打印失败:" + res);
                            }
                        })
                        .catch((error) => {
                            //默认明细
                            this.$message.error("错误1:" + error);
                            console.log("error", error);
                        });
                    }
                }
            }
        },

        //先处理登记信息在打印
        TaskSavePrint()
        {
                //打印前的登记保存
                let tempRegisterTable = this.RegisterTableData;
                let Rowcount =tempRegisterTable.length;
                if (Rowcount==0&&this.PatientInfo['pat_no']) {
                    // edit = true
                    this.PrintRegisterSave(true);
                }
                for (let previousIndex = 0; previousIndex <Rowcount ; previousIndex++) {
                    let element = tempRegisterTable[previousIndex];
                //修改登记信息
                if (element.smp_registerno==this.specno) {
                    //patientinfo 如果与row不相等
                    //edit = 'edit';
                    //校验patientinfo 与 row数据不一致 则修改
                    let canEdit = false;
                        for(var field in this.PatientInfo)
                        {
                            if (field == 'smp_registerdate'||field == 'smp_registerno')
                            continue;
                            if(typeof(field) == 'undefined')
                            break;
                            if (field) {
                                if (this.PatientInfo.hasOwnProperty(field)) {
                                if (!deepEqual(this.PatientInfo[field],this.OldPatientInfo[field])) {
                                    console.log(field);
                                    console.log(this.PatientInfo[field]);
                                    console.log(this.OldPatientInfo[field]);
                                    canEdit=true;
                                    edit =true;
                                    break;
                                }
                            }
                        }

                        }
                    //修改登记信息后打印(弹窗提示是否修改)
                    if(canEdit)
                    this.PrintRegisterSave(true)
                    break;
                }
                //新增登记信息
                if (previousIndex==tempRegisterTable.length-1) {
                    let canAdd = false;
                        for(var field in this.PatientInfo)
                        {
                            if (field == 'smp_registerdate'||field == 'smp_registerno')
                            continue
                            if(typeof(field) == 'undefined')
                            break
                            if (field) {
                                if (this.PatientInfo.hasOwnProperty(field)) {
                                if (this.PatientInfo[field]) {
                                    canAdd=true
                                    edit = true
                                    break
                                }
                            }
                            }
                        }
                    //新增登记信息后打印(弹窗提示是否新增)
                    if(canAdd){
                            this.PrintRegisterSave(true)
                    }

                  }
                }

        },
        //查询登记信息
        smpRegisterQueryPromise()
        {
            console.log('登记日期: ',this.selectdate);
            // let tempDateTime =
            this.$tool
                .request({
                    url: "SMP/SMP2/SMP210",
                    method: "post",
                    data: {
                        action: "smp_register_query",
                        keystr: this.txtSearch,
                        regdate:this.selectdate instanceof Date?formatDate(this.selectdate):this.selectdate,
                        librid: this.selLibrid,
                        specno:this.specno,
                    },
                })
                 .then((res) => {
                    console.log("res", res);
                    if (res) {
                        this.RegisterTableData = res.RegisterRData.Data;
                        //this.$refs.xTable.updateListenter();
                        if (this.RegisterTableData.length>0) {
                            let tempSpecno =this.specno;


                            let tempData = this.RegisterTableData;

                            for (let index = 0; index < tempData.length; index++) {
                                let element = tempData[index];
                                //已存在登记信息
                                if (element.smp_registerno==tempSpecno) {
                                    //选中当前行
                                    this.$refs.xTable.setCurrentRow(this.RegisterTableData[index])
                                    //强制刷新TABLE UI
                                    //this.$refs.xTable.updateListenter();

                                    this.RegisterRowClick('',this.RegisterTableData[index]['smp_registerid'],res);
                                    //查询明细表(明细对应的样本类型)

                                    //单独查询样本信息
                                    //this.smpSampleInfoQuery(this.RegisterTableData[index]['smp_registerid']);
                                    break;
                                }
                                else if (index ==tempData.length-1) {
                                    //清空xTable行
                                    this.InitPatientInfo();
                                    //加载默认样本类型模板
                                    this.initSmpDetailRowDisplay();
                                    //清空打印信息
                                    this.SampleTableData =[];
                                }
                            }
                        }
                        else
                        {
                            //清空xTable行
                            this.InitPatientInfo();
                            //加载默认样本类型模板
                            this.initSmpDetailRowDisplay();
                            //清空打印信息
                            this.SampleTableData =[];
                        }

                    }
                })
                .catch((error) => {
                    this.$message.error("错误1:" + error);
                    console.log("error", error);
                });
        },
        //Promise查询
        smpDetailQueryPromise(RegisterID)
        {
            this.DetailLoading = true;
            if (RegisterID) {
                 this.$tool
                .request({
                     url: "SMP/SMP2/SMP210",
                    method: "post",
                    data: {
                        action: "smp_register_query_byid",
                        smp_registerid: RegisterID,
                        librid: this.selLibrid,
                         },
                })
                 .then((res) => {
                     //已有明细
                     if (res.RDetail&&this.OldPatientInfo['smp_registerid']) {
                         for (let index = 0; index < res.RDetail.Data.length; index++) {
                             res.RDetail.Data[index]['ischk'] ='1';
                         }
                            this.DetailTableData= res.RDetail.Data;
                            this.DetailTableData.sort((a, b) => {
                            let seq1 = a.seq
                            let seq2 = b.seq
                            return a.seq - b.seq
                        })
                     }
                     //默认明细
                     else{
                         this.initSmpDetailRowDisplay();
                     }
                     //条码样本信息
                     if (res.RSample&&this.OldPatientInfo['smp_registerid']) {
                         this.SampleTableData = res.RSample.Data;

                     }
                    this.$nextTick(()=>{
                    this.thePrintDetail();
                    });
                })
                .catch((error) => {
                    //默认明细
                    this.$message.error("错误1:" + error);
                    console.log("error", error);
                });
            }

        },


        //空格
        SpaceEvent(type) {
            var val = this.PatientInfo[type + "name"];
            if (!val.replace(/\s*/g, "")) {
                this.inputdblEvent(type);
            }
        },
        //Tab控件响应编辑区移动到下一个控件
        TabEvent(colcode,keytype) {
            // console.log("TabEvent ", colcode);
            this.DatePikerInputMove(1, colcode);
            //this.$refs.editedit.$el.focus();
        },
        //Enter控件响应编辑区移动到下一个控件
        EnterEvent(colcode,keytype) {
            // console.log("EnterEvent ", colcode);

            this.InputMove(1, colcode);
            //this.$refs.editedit.$el.focus();
        },
        //输入框移动
        InputMove(type, colcode) {
            //0上移1下移
            if (type == 1) {
                var num = 0;
                for (let i = 0; i < this.ColData.length; i++) {
                    if (this.ColData[i].col_code == colcode) num = i;
                }
                var nextitem = this.ColData[num + 1];
                num = num + 1;
                if (num < this.ColData.length && num > -1) {
                    while (!nextitem.enabled && num < this.ColData.length - 1) {
                        nextitem = this.ColData[num + 1];
                        num = num + 1;
                    }
                    //this.$refs[nextitem][0].focus();
                    if (this.$refs[nextitem.col_code][0]) {
                        if (nextitem.col_code.toUpperCase().indexOf("_DT") == -1 && nextitem.col_code.toUpperCase().indexOf("_DATE") == -1 && this.$refs[nextitem.col_code][0]['type']!="datetime") {
                            this.$nextTick(() => {


                                this.$refs[nextitem.col_code][0].focus();
                            });
                        } else {
                            console.log('我在picker的移动',this.$refs[nextitem.col_code][0]);
                            this.$refs[nextitem.col_code][0].$refs.reference.$refs.input.focus();
                            // this.$refs[nextitem.col_code][0].focus();
                            this.$refs[nextitem.col_code][0].hidePicker();
                        }
                    }
                } else {
                    this.$refs['pat_no'][0].select();
                }
            } else {
                var num = 0;
                for (let i = 0; i < this.ColData.length; i++) {
                    if (this.ColData[i].col_code == colcode) num = i;
                }
                var nextitem = this.ColData[num - 1];
                num = num - 1;
                if (num < this.ColData.length && num > -1) {
                    while (!nextitem.enabled && num > 0) {
                        nextitem = this.ColData[num - 1];
                        num = num - 1;
                    }
                    //this.$refs[nextitem][0].focus();
                    if (this.$refs[nextitem.col_code][0]) {
                        if (nextitem.col_code.toUpperCase().indexOf("_DT") == -1 && nextitem.col_code.toUpperCase().indexOf("_DATE") == -1) {
                            this.$nextTick(() => {

                                this.$refs[nextitem.col_code][0].focus();
                            });
                        } else {
                            this.$refs[nextitem.col_code][0].focus();
                            this.$refs[nextitem.col_code][0].hidePicker();
                        }
                    }
                } else {
                    this.$refs.barcode[0].select();
                }
            }
        },
        //输入框移动
        DatePikerInputMove(type, colcode) {
            //0上移1下移
            if (type == 1) {
                var num = 0;
                for (let i = 0; i < this.ColData.length; i++) {
                    if (this.ColData[i].col_code == colcode) num = i;
                }
                if (num<this.trNum) {
                    num = (this.tdNum-1)*this.trNum+num-1;
                }
                else if (num>this.trNum) {
                    num =num-this.trNum-1
                }
                var nextitem = this.ColData[num + 1];
                num = num + 1;
                if (num < this.ColData.length && num > -1) {
                    while (!nextitem.enabled && num < this.ColData.length - 1) {
                        nextitem = this.ColData[num + 1];
                        num = num + 1;
                    }
                    //this.$refs[nextitem][0].focus();
                    if (this.$refs[nextitem.col_code][0]) {
                        if (nextitem.col_code.toUpperCase().indexOf("_DT") == -1 && nextitem.col_code.toUpperCase().indexOf("_DATE") == -1 && this.$refs[nextitem.col_code][0]['type']!="datetime") {
                            this.$nextTick(() => {


                                this.$refs[nextitem.col_code][0].focus();
                            });
                        } else {
                            console.log(this.$refs[nextitem.col_code][0]);
                            this.$refs[nextitem.col_code][0].$refs.reference.$refs.input.focus();
                            this.$refs[nextitem.col_code][0].focus();
                            this.$refs[nextitem.col_code][0].hidePicker();
                        }
                    }
                } else {
                    this.$refs['pat_no'][0].select();
                }
            } else {
                var num = 0;
                for (let i = 0; i < this.ColData.length; i++) {
                    if (this.ColData[i].col_code == colcode) num = i;
                }
                var nextitem = this.ColData[num - 1];
                num = num - 1;
                if (num < this.ColData.length && num > -1) {
                    while (!nextitem.enabled && num > 0) {
                        nextitem = this.ColData[num - 1];
                        num = num - 1;
                    }
                    //this.$refs[nextitem][0].focus();
                    if (this.$refs[nextitem.col_code][0]) {
                        if (nextitem.col_code.toUpperCase().indexOf("_DT") == -1 && nextitem.col_code.toUpperCase().indexOf("_DATE") == -1) {
                            this.$nextTick(() => {

                                this.$refs[nextitem.col_code][0].focus();
                            });
                        } else {
                            this.$refs[nextitem.col_code][0].focus();
                            this.$refs[nextitem.col_code][0].hidePicker();
                        }
                    }
                } else {
                    this.$refs.barcode[0].select();
                }
            }
        },
        //input输入框双击事件
        inputdblEvent(colcode) {
            this.popdatatype = "SMP210_" + colcode;
            let selitem = this.tableDataColumn.find(item => item.col_code == colcode);
            if (selitem && selitem.noedit) {
                return;
            }
            if (colcode === "pat_agestr") {
                if (this.PatientInfo[colcode]) {
                    var re1 = new RegExp("\\d+(?=" + this.radiofatherunit + ")", "g");
                    var re2 = new RegExp("\\d+(?=" + this.radiosonunit + ")", "g");
                    var age1 = this.PatientInfo[colcode].match(re1);
                    var age2 = this.PatientInfo[colcode].match(re2);
                    if (age1) {
                        this.inputfatherage = age1[0];
                    } else {
                        this.inputfatherage = "";
                    }
                    if (age2) {
                        this.inputsonage = age2[0];
                    } else {
                        this.inputsonage = "";
                    }
                    this.reagestrch = this.PatientInfo[colcode];
                }

                this.dialogAgeVisible = true;
            } else if (colcode == "lab_advice") {
                //this.advicetxt = this.PatientInfo[colcode].replace(/\\n/g, "\n");
                this.QueryAdvice();
                if (localStorage.getItem("floatwindowstyle3")) this.floatwindowstyle3 = localStorage.getItem("floatwindowstyle3");
                this.dialogAdvicefloatwindowVisible = true;
            } else {
                this.popdatatype = "SMP210_" + colcode;
                this.dialogTableVisible = true;
            }
        },
        //焦点事件 valuetype == 5
         InputFocus(colcode) {
            this.popdatatype = "SMP210_" + colcode;
            this.Queryddl();
            console.log(this.InputCodeArr);
            console.log(this.$refs[colcode]);
            if (colcode == "specno") {
                this.$refs.specno.select();
            } else if (colcode == "lab_advice") {
                this.QueryAdvice();
                this.$refs[colcode][0].select();
            } else {
                if (colcode.toUpperCase().indexOf("_DT") == -1 && colcode.toUpperCase().indexOf("_DATE") == -1 && this.$refs[colcode][0]['type']!='datetime') {
                    this.$refs[colcode][0].select();
                } else {
                    this.$refs[colcode][0].focus();
                }
            }

        },
        //焦点事件 valuetype == 5 (该方法只在点击样本登记信息行的时候调用)
         ClickInputFocus(value,colcode) {
            this.popdatatype = "SMP210_" + colcode;
            this.ClickQueryddl(value,colcode);
        },
        //焦点事件 valuetype == 3
         InputDropdownFocus(colcode) {
            this.popdatatype = "SMP210_" + colcode;
            this.QueryDropdownLoad(colcode);
            console.log(this.$refs[colcode]);
            if (colcode == "specno") {
                this.$refs.specno.select();
            } else if (colcode == "lab_advice") {
                this.QueryAdvice();
                this.$refs[colcode][0].select();
            } else {
                if (colcode.toUpperCase().indexOf("_DT") == -1 && colcode.toUpperCase().indexOf("_DATE") == -1 && this.$refs[colcode][0]['type']=='datetime') {
                    this.$refs[colcode][0].select();
                } else {
                    this.$refs[colcode][0].focus();
                }
            }
        },
        //Input输入框控件类型为5的change事件
        popinputchange(value, type) {
            if (this.Options.inputasreportuser == "0" && type != "rechk_user" && type != "report_user") {
                this.PatientInfo.report_username = this.exactusernamereport;
                this.PatientInfo.report_user = this.exactusernoreport;
            }
            switch (type) {
                case "pat_agestr":
                    var reg = new RegExp("\\d{1,}(y|Y|岁|年){0,}\\d{0,}(m|M|月){0,}\\d{0,}(d|D|日){0,}\\d{0,}(h|H|小时){0,}\\d{0,}(f|F|分钟){0,}", "gi");
                    var regd = new RegExp("^\\d{1,}$", "gi");
                    var regda = new RegExp("\\d{1,}", "gi");
                    if (value.match(regd)) {
                        this.PatientInfo[type] = value + "岁";
                        this.PatientInfo["pat_ageyear"] = value - 0;
                    } else if (value.match(reg)) {
                        this.PatientInfo[type] =
                            value
                                .replace("y", "岁")
                                .replace("年", "岁")
                                .replace("Y", "岁")
                                .replace("m", "月")
                                .replace("M", "月")
                                .replace("d", "日")
                                .replace("D", "日")
                                .replace("h", "小时")
                                .replace("H", "小时")
                                .replace("f", "分钟")
                                .replace("F", "分钟") + "";
                        this.PatientInfo.pat_ageyear = this.ageTransform(this.PatientInfo.pat_agestr);
                    } else {
                        this.$confirm("无效的病人年龄!", "提示", {
                            confirmButtonText: "确定",
                            cancelButtonText: "取消",
                            focusCancelButton: false,
                            closeOnClickModal: false,
                            type: "warning"
                        })
                            .then(() => {})
                            .catch(() => {});
                    }
                    break;
                case "lab_advice":
                    var list = this.InputCodeArr.filter(item => item.key == this.popdatatype);
                    if (list.length > 0) {
                        var row = list[0].list.Data.filter(item => (item.txtinfo + "").toUpperCase() == (value + "").toUpperCase() || (item.txttitle + "").toUpperCase() == (value + "").toUpperCase() || (item.inputcode + "").toUpperCase() == (value + "").toUpperCase());
                        if (row.length > 0) {
                            this.PatientInfo[type] = row[0].txtinfo;
                        }
                    }
                    break;
                default:
                    let selitem = this.tableDataColumn.find(item => item.col_code == type);
                    if (selitem && selitem.noedit) {
                        return;
                    }
                    if (value.trim()) {
                        var list = this.InputCodeArr.filter(item => item.key == this.popdatatype);
                        if (list.length > 0) {
                            var row = list[0].list.Data.filter(item => (item.inputcode + "").toUpperCase() == (value + "").toUpperCase() || (item.hidkey + "").toUpperCase() == (value + "").toUpperCase());
                            if (row.length > 0) {
                                if (type == "rechk_user" || type == "report_user") {
                                    this.usercode = row[0].hidkey;
                                    this.username = row[0].hidname;
                                    this.userpwd = "";
                                    this.dialogLoginVisible = true;
                                    this.$nextTick(() => {
                                        this.$refs.loginpwd.focus();
                                    });
                                } else {
                                    this.PatientInfo[type + "name"] = row[0].hidname;
                                    this.PatientInfo[type] = row[0].hidkey;
                                }
                            } else {
                                if (type == "pat_sex" || type == "pat_typecode" || type == "specimen_code" || type == "rechk_user" || type == "report_user") {
                                    this.dialogTableVisible = true;
                                } else {
                                    var re = new RegExp("[\\u4e00-\\u9fa5]", "gi");
                                    if (!re.test(value)) {
                                        this.dialogTableVisible = true;
                                    }
                                }
                            }
                        }
                    } else {
                        this.PatientInfo[type] = "";
                    }
                    break;
            }
        },
        //输入框控件类型为2改变事件
        inputChangeEvent(value, type) {
            if (!this.changekeyflag) {
                if (this.Options.inputasreportuser == "0") {
                    this.PatientInfo.report_username = this.exactusernamereport;
                    this.PatientInfo.report_user = this.exactusernoreport;
                }
                switch (type) {
                    case "pat_no":
                        // this.changekeyflag = true;
                        // this.ExecPatNoChange(value, type)
                        //     .then(() => {
                        //         this.changekeyflag = false;
                        //     })
                        //     .catch(() => {
                        //         this.changekeyflag = false;
                        //     });

                        break;
                    case "barcode":
                        this.changekeyflag = true;
                        // var hasdata = this.$refs.xTableList.tableFullData.filter(item => item.sampleno == this.specno);
                        // if (this.PatientInfo.barcode != this.oldbarcode && hasdata.length > 0) {
                        //     if (hasdata[0].pat_name || hasdata[0].pat_no || hasdata[0].pat_typecode) {
                        //     }
                        // }
                        // this.ExecBarcodeChange()
                        //     .then(() => {
                        //         this.changekeyflag = false;
                        //     })
                        //     .catch(() => {
                        //         this.changekeyflag = false;
                        //     });
                        break;
                }
            }
        },
        //鼠标悬浮在控件上触发该事件
          tooltipmousover(col, valuetype) {
            if (valuetype == 5) {
                this.tooltipcontent = this.PatientInfo[col + "name"];
                if (this.tooltipcontent && this.tooltipcontent.length > 12) {
                    this.tooltipsdiable = false;
                } else {
                    this.tooltipsdiable = true;
                }
            } else if (valuetype != 7) {
                this.tooltipcontent = this.PatientInfo[col];
                if (this.tooltipcontent && this.tooltipcontent.length > 12) {
                    this.tooltipsdiable = false;
                } else {
                    this.tooltipsdiable = true;
                }
            }
        },
          //弹出框关闭时自动保存
        popcommonclose() {
            var typecol = (this.popdatatype + "").replace("SMP210_", "");
            if (this.$refs[typecol]) {
                this.$refs[typecol][0].select();
            }
            if (typecol == "specimen_code") {
                var value = this.PatientInfo.specimen_codename;
                var list = this.InputCodeArr.filter(item => item.key == this.popdatatype);
                var row = list[0].list.Data.filter(item => (item.inputcode + "").toUpperCase() == (value + "").toUpperCase() || (item.hidkey + "").toUpperCase() == (value + "").toUpperCase() || item.hidname.toUpperCase() == value.toUpperCase());
                if (row.length == 0) {
                    this.PatientInfo.specimen_codename = "";
                    this.PatientInfo.specimen_code = "";
                }
            }
        },
        //公共组件change事件
        popchange(c, v, row) {
            if (this.Options.inputasreportuser == "0") {
                this.PatientInfo.report_username = this.exactusernamereport;
                this.PatientInfo.report_user = this.exactusernoreport;
            }
            if (this.popdatatype != "SMP210_report_user" && this.popdatatype != "SMP210_rechk_user") {
                var colcode = this.popdatatype.replace("SMP210_", "");
                this.PatientInfo[colcode] = c;
                this.PatientInfo[colcode + "name"] = v;
                this.dialogTableVisible = false;
                this.$refs[colcode][0].select();
            } else {
                this.usercode = c;
                this.username = v;
                this.userpwd = "";
                this.dialogLoginVisible = true;
                this.dialogTableVisible = false;
            }
        },
        //valuetype 1 radio-button-group chage事件
          selectChange(fieldName)
        {
              this.$nextTick(() => {
                if (this.PatientInfo[fieldName] == "1") {

                } else {

                }
            });
        },
         configDefChange({ row, colcode }) {
            var selitem = this.tableDataColumn.find((item) => item.col_code == colcode);
            if (selitem) {
                var index = this.tableDataColumn.indexOf(selitem);
                if (row != "") {
                    this.tableDataColumn[index].default_val = row.hidkey;
                    this.tableDataColumn[index].default_valname = row.hidname;
                } else {
                    this.tableDataColumn[index].default_val = "";
                    this.tableDataColumn[index].default_valname = "";
                }
            }
            this.$refs.ElementConfig.$refs.xTableColumn.loadData(this.tableDataColumn);
        },
        ConfigClose() {
            // this.GetOptions(this.rptunitid).then(() => {
            //     this.QueryCol();
            // });
        },
        Loadvaluetype1(fieldName)
        {
            this.PatientInfo[fieldName] = '0';
        },
        async inputRegisterNum()
        {

        },
        //补打条码
        async RePrintBarcode()
        {

        },
        //查看日志
        async QueryRegisterLog()
        {

        },
        //清除未做
        async ClearNoDoItems()
        {

        },
        //清除打印标志
        async ClearPrintFlag()
        {

        },
        //查询样本库登记---初始化输入字段表valuetype为3的下拉框Option绑定的数据
         Load_DropdownAll(res)
        {
            //valuetype 为3的固定绑定值
            let  field_code ;
            for (let index = 0; index < res.length; index++) {
                const element = res[index];
                //初始化下拉框
                if (element.valuetype =='3') {
                    let stroption ;
                    //1 本院|2 外院 pat_sourcetype  标本来源
                    if (element.col_code=='pat_sourcetype') {
                        stroption = [{'key':'1','value':'本院'},{'key':'2','value':'外院'}];
                        this.popdropdwon_Options[element.col_code] = stroption;
                    }
                    //0 无|1 有|2 不详  familyornot  家族史
                    if (element.col_code=='familyornot') {
                        stroption = [{'key':'0','value':'无'},{'key':'1','value':'有'},{'key':'2','value':'不详'}];
                        this.popdropdwon_Options[element.col_code] = stroption;
                    }
                    //1 初级库|2 建系|3 主库  cellclass  细胞类别
                     if (element.col_code=='cellclass') {
                        stroption = [{'key':'1','value':'初级库'},{'key':'2','value':'建系'},{'key':'3','value':'主库'}];
                        this.popdropdwon_Options[element.col_code] = stroption;
                    }
                    //C C属|W W属|V V属  celllevel  细胞等级
                     if (element.col_code=='celllevel') {
                        stroption = [{'key':'C','value':'C属'},{'key':'V','value':'W属'}];
                        this.popdropdwon_Options[element.col_code] = stroption;
                    }
                    //1 合格|2 不合格  cellqcflag  细胞质控标志
                     if (element.col_code=='cellqcflag') {
                        stroption = [{'key':'1','value':'合格'},{'key':'2','value':'不合格'}];
                        this.popdropdwon_Options[element.col_code] = stroption;
                    }
                }
                //初始化单选框
                else if (element.valuetype =='1') {
                    // let stroption ;
                    // this.PatientInfo[element.col_code] =0;
                    // //0 否|1 是   istransfer  远处转移
                    // if (element.col_code=='istransfer') {
                    //     this.PatientInfo[element.col_code] = '0';
                    // }
                    // //0 否|1 是   isoperation  是否手术
                    // if (element.col_code=='isoperation') {
                    //     this.PatientInfo[element.col_code] = stroption;
                    // }
                    // //0 否|1 是   antivirus  抗病毒治疗
                    // if (element.col_code=='antivirus') {
                    //     this.PatientInfo[element.col_code] = stroption;
                    // }
                }

            }

        },
        //样本库查询UI设置
        HisUI(res)
        {
                //样本登记信息table的<tr>行数
                var num = parseInt((this.$refs.xTableDiv.offsetHeight - 40) /28); //
                this.trNum = num;

                //上一个 下一个排序绑定变量
                this.ColData = res.slice(0, res.length);
                //#region

                var data = [];
                //data2是 res中除了smp_registerdate 和 smp_registerno的对象数组
                var data2 = [];
                console.log(data.length);
                //单独绑定登记日期  登记序号
                for (let index = 0; index < res.length; index++) {
                    if (res[index].col_code==="smp_registerdate") {
                            this.RegisterDate =res[index];
                    }
                    else if (res[index].col_code==="smp_registerno") {
                            this.RegisterSeq =res[index];
                    }
                    else
                    {
                        data2.push(res[index]);
                    }
                }
                console.log('OKOKOK',this.RegisterDate);

                //每个tr平均多少个字段
                var fieldLength = parseInt(data2.length/num);
                this.tdNum = fieldLength;
                //余数
                var fieldRemainder = data2.length%num;

                //表格綁定数据排序
                //     for (let k = 0; k <num; k++) {
                //         let tempArray =[];
                //     for (let j = 0; j < fieldLength; j++) {
                //         let tempValue=[];
                //             if(k==0)
                //             {
                //                 tempValue =data2[j*num];
                //             }
                //             else{
                //                 tempValue =data2[j*num+k];
                //             }
                //             tempArray.push(tempValue);
                //     }
                //     if (k<fieldRemainder) {
                //         tempArray.push(data2[num*fieldLength+k]);
                //     }
                //     data.push(tempArray);
                // }
                // console.log("🚀 ColTotalData排序", this.ColTotalData);


                //     for (let i = 0; i <num; i++) {
                //     this.ColTotalData.push(data[i]);
                // }

                    //表格綁定数据排序
                    for (let k = 0; k <num; k++) {
                        let tempArray =[];
                    for (let j = 0; j < fieldLength; j++) {
                        let tempValue=[];
                            if(k==0)
                            {
                                tempValue =data2[j*num];
                            }
                            else{
                                tempValue =data2[j*num+k];
                            }
                            tempArray.push(tempValue);
                    }
                    if (k<fieldRemainder) {
                        tempArray.push(data2[num*fieldLength+k]);
                    }
                    data.push(tempArray);
                }
                    for (let i = 0; i <num; i++) {
                    this.ColTotalData.push(data[i]);
                }


                    this.HisTdWidth =[];
                //计算His Table每列Td Label宽度

                for (let index = 0; index < fieldLength; index++) {
                    let columnsWidth =0;

                        for (let index1 = 0; index1 <num; index1++) {
                            let tempnum = data[index1][index].col_label.length*12;
                            if (columnsWidth<tempnum) {
                                columnsWidth =tempnum;
                            }
                        }
                            if (index===0) {
                        //保持登记序号与内容列宽度对其
                        this.RegisterDateTitleWidth =columnsWidth;
                    }
                            if (index===1) {
                        //保持登记序号与内容列宽度对其
                        this.RegisterTitleWidth =columnsWidth;
                    }
                        if (index===2) {
                        //保持登记序号与内容列宽度对其
                        this.SampleBankTitleWidth =columnsWidth;
                    }
                    this.HisTdWidth.push(columnsWidth);
                }
                console.log('YEYEYEYEYE',this.HisTdWidth);
                let columnsRemainderWidth =0;
                //计算His Table每列Td Label宽度(余数)
                for (let RemainderIndex = fieldLength *num; RemainderIndex < data2.length; RemainderIndex++) {
                    if (columnsRemainderWidth<data2[RemainderIndex].col_label.length*12) {
                        columnsRemainderWidth =data2[RemainderIndex].col_label.length*12;
                    }
                }
                if(columnsRemainderWidth>0)
                {
                    this.HisTdWidth.push(columnsRemainderWidth);
                }
                //初始化滚动条的初始展开位置(保持好看)
                this.initScrollPosition = this.$refs.SampleBankWidth.offsetLeft+ this.$refs.SampleBankWidth.offsetWidth+350;
                //#endregion

                this.$nextTick(() => {
                this.loadSpecimenTypeDialog();//初始化样本类型弹窗
                this.loadvxeSpecimenType();
                });
        },
    /**vxe-table 样本库登记信息 */
         RegisterRowClick(RegisterTableData,smpDetailQueryPromise,allRes)
        {
            try {
                //this.$refs.xTable.updateListenter();
                let  currentRowData = this.$refs.xTable.getCurrentRow();
                let  smp_registerId = '';


                if (currentRowData) {

                    for(let field in currentRowData)
                    {
                        if (this.PatientInfo.hasOwnProperty(field)) {
                            //过滤序号
                            if (field == 'smp_registerno') {
                                if(currentRowData[field])
                                {
                                    this.PatientInfo[field] =currentRowData[field];
                                    this.OldPatientInfo[field] =currentRowData[field];
                                    this.specno =currentRowData[field];
                                }
                            }
                            else if (field == 'smp_registerid') {
                                if(currentRowData[field])
                                {
                                    this.PatientInfo[field] =currentRowData[field];
                                    this.OldPatientInfo[field] =currentRowData[field];
                                    smp_registerId =currentRowData[field];
                                }
                            }
                            // if (field =='smp_registerno') {
                            //     this.specno =currentRowData[field];
                            // }
                            else if (field =='smp_registerdate') {
                                //字符串日期转为date类型日期
                                if(currentRowData[field])
                                {
                                    this.selectdate =new   Date(Date.parse(currentRowData[field].replace(/-/g, "/")));
                                    this.PatientInfo[field] =currentRowData[field];
                                    this.OldPatientInfo[field] = this.selectdate;
                                }
                            }
                            //日期字段全部都需要转换为Dete类型
                            else if(field =='pat_birth'||field =='operationdate'||field =='smpdate')
                            {
                                if(currentRowData[field])
                                {
                                    this.PatientInfo[field] = new   Date(Date.parse(currentRowData[field].replace(/-/g, "/")));
                                    this.OldPatientInfo[field] =new   Date(Date.parse(currentRowData[field].replace(/-/g, "/")));
                                }
                            }
                            else
                            {
                                if(field =='pat_sex'||field =='pat_sexname')
                                {
                                    let s =1;
                                }
                                this.PatientInfo[field] =currentRowData[field];
                                this.OldPatientInfo[field] =currentRowData[field];
                            }

                            //

                        }
                    }
                    console.log('选中行赋值完毕!:',new Date());
                }
                else
                {
                    this.InitOldPatientInfo();
                }
                //this.$refs.xTable.updateListenter();
                if (!allRes) {
                    //刷新明细
                    if (RegisterTableData) {
                        this.smpDetailQuery(RegisterTableData);
                    }
                    if (smpDetailQueryPromise) {
                        this.smpDetailQueryPromise(smpDetailQueryPromise);
                    }
                    if (!RegisterTableData  && !smpDetailQueryPromise ) {
                        this.smpDetailQuery(smp_registerId);
                    }
                }
                else{
                    //条码样本信息
                    //  if (res.RSample&&this.OldPatientInfo['smp_registerid']) {
                    //      if(res.RSample.Data)
                    //      {
                    //         this.SampleTableData = res.RSample.Data;
                    //         tempSampleData = res.RSample.Data;
                    //      }
                    //  }
                    //  //已有明细
                    //  if (res.RDetail&&this.OldPatientInfo['smp_registerid']) {
                    //      if (res.RDetail.Data) {
                    //             //显示是否勾选打印明细(不是"已打印")
                    //             if (tempSampleData) {
                    //                 for (let index = 0; index < res.RDetail.Data.length; index++) {
                    //                      let rowDetail =  res.RDetail.Data[index];
                    //                     if (rowDetail.hasOwnProperty('isbarcodeprint')) {
                    //                         if (res.RDetail.Data[index]['isbarcodeprint'] =='0') {
                    //                             res.RDetail.Data[index]['ischk'] ='1';
                    //                         }
                    //                         else
                    //                         {
                    //                             let sumPrint = 0;
                    //                             for (let idx = 0; idx < tempSampleData.length; idx++) {
                    //                                 const rowSmp = tempSampleData[idx];
                    //                                 if (rowSmp["smp_registerid"]==rowDetail["smp_registerid"]&&rowSmp["smp_type"]==rowDetail["smp_type"]) {
                    //                                     sumPrint++;
                    //                                     if (sumPrint==rowDetail["smp_number"]) {
                    //                                         break;
                    //                                     }
                    //                                 }
                    //                             }
                    //                             res.RDetail.Data[index]["smp_sumprint"] = sumPrint;
                    //                         }
                    //                     }
                    //             }
                    //         }
                    //             this.DetailTableData= res.RDetail.Data;
                    //             this.DetailTableData.sort((a, b) => {
                    //             let seq1 = a.seq
                    //             let seq2 = b.seq
                    //             return a.seq - b.seq
                    //         })
                    //      }
                    //  }
                    //  //默认明细
                    //  else{
                    //      this.initSmpDetailRowDisplay();
                    //  }

                    let tempSampleData;
                    //样本信息打印
                    if (allRes.RSample) {
                        //条码样本信息
                        if (allRes.RSample&&this.OldPatientInfo['smp_registerid']) {
                            if(allRes.RSample.Data)
                            {
                                this.SampleTableData = allRes.RSample.Data;
                                tempSampleData = allRes.RSample.Data;
                            }
                        }
                    }
                    //样本登记明细
                    if (allRes.RDetail) {
                        if (allRes.RDetail&&this.OldPatientInfo['smp_registerid']) {
                            if (allRes.RDetail.Data) {
                                //显示是否勾选打印明细(不是"已打印")
                                if (tempSampleData) {
                                    for (let index = 0; index < allRes.RDetail.Data.length; index++) {

                                        let rowDetail =  allRes.RDetail.Data[index];
                                        if (rowDetail.hasOwnProperty('isbarcodeprint')) {
                                            if (allRes.RDetail.Data[index]['isbarcodeprint'] =='0') {
                                                allRes.RDetail.Data[index]['ischk'] ='1';
                                            }
                                             else
                                            {
                                                let sumPrint = 0;
                                                for (let idx = 0; idx < tempSampleData.length; idx++) {
                                                    const rowSmp = tempSampleData[idx];
                                                    if (rowSmp["smp_registerid"]==rowDetail["smp_registerid"]&&rowSmp["smp_type"]==rowDetail["smp_type"]) {
                                                        sumPrint++;
                                                        if (sumPrint==rowDetail["smp_number"]) {
                                                            break;
                                                        }
                                                    }
                                                }
                                                allRes.RDetail.Data[index]["smp_sumprint"] = sumPrint;
                                            }
                                        }
                                    }
                                }
                                    this.DetailTableData= allRes.RDetail.Data;
                                    this.DetailTableData.sort((a, b) => {
                                    let seq1 = a.seq
                                    let seq2 = b.seq
                                    return a.seq - b.seq
                                })
                            }
                        }
                        //默认明细
                        else{
                            this.initSmpDetailRowDisplay();
                        }
                    }
                }
            }
            catch (error) {
                console.log('点击一行登记信息出现错误! ',error);
            }

        },




    /**vxe-table 样本类型的方法 */
    renderHeaderMethod(h, { column})
    {
      const inReview = '需要进行线下发放的奖品项数(非奖品数)，例如，一个中奖项设置奖品A一次中奖数量为2，一共有10人中奖待发放，那次数展示的数量为10，而不是20。已发放奖品项目同理。自动线上发放的虚拟物品不会占用“待发放奖品项数”'
        const inReviews = '需要进行线下发放的奖品项数(非奖品数)，例如，一个中奖项设置奖品A一次中奖数量为2，一共有10人中奖待发放，那次数展示的数量为10，而不是20。已发放奖品项目同理。自动线上发放的虚拟物品不会占用“待发放奖品项数”'
        return h(
　　　　    'div', [
                h('span', column.label),
                h('el-tooltip', {
                    props: {
                        placement: 'top'
                    }
                }, [
                    h('div', {
                        slot: 'content',
                        style: {
                            'width':'250px',
                            whiteSpace: 'normal',
                            'margin-bottom': '10px'
                        }
                    }, inReview),
                    h('div', {
                        slot: 'content',
                        style: {
                            'width':'250px',
                            whiteSpace: 'normal',
                            'margin-bottom': '10px'
                        }
                    }, inReviews),
                    h('i', {
                        class: 'el-icon-warning-outline',
                        style: 'color:red;margin-left:5px;'
                    })
                ],)
            ]
　　　　 )

    },
    //打开编辑样本类型弹窗
    async addsmptype({$rowIndex,column,columnIndex,$columnIndex,cell},event){
         //保存 vxe-table 样本类型的ROW缓存数据
        this.addtypedialogTableVisible = true;
        this.StorageSmptypeInfo =[];
         this.$nextTick(()=>{
             if (column.property == "specimen_name") {
            //1.根据样本库ID查询改样本库设置使用的样本类型
            if (this.selLibrid) {
            //1.判断本地样本类型有没有设置缓存对象
            this.localName = 'SMP210_librid_'+this.selLibrid;
            let SmpSpecimenType = this.$tool.getLocalConfig(this.localName);
            console.log('当前本地保存的行数据!:',SmpSpecimenType);
            //2.如果有 将当前缓存对象的勾选记录保存到样本类型弹窗。
            if (SmpSpecimenType) {
                //StorageSmptypeInfo 是弹框ROW勾选框ID绑定数据源


                //获取 getData
                let temptypeData = this.$refs.ddlcommonTable.getData();
                //getColumns(columnIndex)
                let temptypeDataC = this.$refs.ddlcommonTable.getColumns();
                if (temptypeData) {
                    console.log('table',temptypeData);
                    console.log('columnss',temptypeDataC);
                    console.log('this.tableData',this.tableData);
                //重新刷新 gird specimen_code
                // for (let index = 0; index < this.tableData.length; index++) {
                //     this.tableData[index]['specimen_code']='row_'+(index+1);

                // }

                //重新刷新 gird  col_ID
                // for (let index = 0; index < this.tableData.length; index++) {
                //     this.tableData[index]['gridID']='row_'+(index+1);

                // }

                SmpSpecimenType.forEach(obj=>{
                   temptypeData.forEach(row=>{
                       if (obj['specimen_code']==row['specimen_code'] && obj['librid']==row['librid']) {
                           this.StorageSmptypeInfo.push(row['specimen_code']);
                        }
                            });
                        });
                }
                //this.$refs.ddlcommonTable.setSelection(SmpSpecimenType,this.StorageSmptypeInfo);
                this.$refs.ddlcommonTable.setSelection(SmpSpecimenType,true);
            }
            // else
            // {
            //     this.tableData =[];
            // }

            }
          }
         });


    },
    editDetailRow(row)
    {
          // "smp_regdetailid": "",
        // "smp_registerid": 7224,
        // "smp_type": "0006",
        // "smp_number": 2,
        // "smp_quantity": 1.2,
        // "smp_unit": "ml",
        // "ischk": null,
        // "specimen_name": null,
        // "_XID": "row_19"

        const thisTableData = this.DetailTableData;

        let tempRowData = {};
        tempRowData.ischk = '1';
        tempRowData.smp_regdetailid = '';
        tempRowData.smp_registerid = '';
        //tempRowData.specimen_code = deepTrim(row.smptype);//deepTrim()
        tempRowData.specimen_code = myTrim(row.specimen_code);
        tempRowData.specimen_name = myTrim(row.specimen_name);
        tempRowData.seq =row.seq;
        tempRowData.smp_quantity = row.volume;
        tempRowData.smp_type = myTrim(row.specimen_code);
        tempRowData.smp_number = row.quantity;
        tempRowData.smp_unit = myTrim(row.unit);
        tempRowData.isbarcodeprint = '0';

        let isadd = false;
        /**勾选样本类型行添加删除明细行 */
        for (let index = 0; index < thisTableData.length; index++) {
            let element = thisTableData[index];
            // if (element.smp_regdetailid) {
            //     // continue;
            // } else {
            //     //删除明细行
            //     if (row.ischk=='1'&& row.smp_type==element.smptype) {
            //         this.DetailTableData.splice(index, 1);
            //         return;
            //     }
            //     //新增明细行
            //     if (row.ischk=='0'&& row.smp_type!=element.smptype) {
            //         if (index==thisTableData.length-1) {
            //             isadd =true;
            //         }
            //         break;
            //     }
            // }

            //删除明细行
            if (row.ischk=='1'&& row.specimen_code==element.smp_type&&!element.smp_regdetailid) {
                this.DetailTableData.splice(index, 1);

                return;
            }
            //新增明细行
            if (row.ischk=='0'&& row.specimen_code!=element.smp_type)
                isadd =true;
            else
            {
                //row.ischk=='1' 代表需要删除ROW,继续循环.
                if (row.ischk=='1') {
                    isadd = false;
                }
                //明细已存在不能新增
                if (row.specimen_code==element.smp_type) {
                    isadd = false;
                    break;
                }
            }


        }
        if ((thisTableData.length==0&& row.ischk=='0')||isadd) {

            this.DetailTableData.push(tempRowData);
            this.DetailTableData.sort((a, b) => {
                    let seq1 = a.seq
                    let seq2 = b.seq
                    return a.seq - b.seq
                })

            return;
        }

    },

    async addvxedetail({row,rowIndex,$rowIndex,column,columnIndex,$columnIndex,cell},event){


        //target 点击的是checkbox 则跳出事件
        if (column.property!='ischk' || event.target.localName==='span') {
            return;
        }
        if(column.property=='ischk')
        {
            this.editDetailRow(row);
            if(row.ischk)
            {
                if(row.ischk=='0')
                {

                    row.ischk='1';
                }
                else
                {
                    row.ischk='0';
                }
            }
            else
            {
                row.ischk ='1';
            }
        }
        this.$refs.xTableSpecimenType.updateListenter();


    },

        async adddetailprint({row,rowIndex,$rowIndex,column,columnIndex,$columnIndex,cell},event){
        //target 点击的是checkbox 则跳出事件
        if (column.property!='ischk' || event.target.localName==='span') {
            return;
        }
        if(column.property=='ischk')
        {
            if(row.ischk)
            {
                if(row.ischk=='0')
                {

                    row.ischk='1';
                }
                else
                {
                    row.ischk='0';
                }
            }
            else
            {
                row.ischk ='1';
            }
        }
        this.$refs.xTableSpecimenType.updateListenter();
    },

    /**弹窗样本类型相关的代码放在这里 */
    popcomchange(c, v) {

            this.specimenVisible = false;
        },


    //设置弹窗grid控件的列
    setcol() {
            var collist = [];
            if (this.multiple) {
                collist.push({ type: "selection", width: 50, align: "center" });

            }
            for (let i = 0, len = this.fulldata.Cols.length; i < len; i++) {
                const item = this.fulldata.Cols[i];
                if (item.field != "hidkey" && item.field != "hidname" && item.field != "inputcode" && item.field != "shortmsgcode") {
                    let colitem = {
                        field: item.field,
                        title: item.title,
                        width: item.width,
                    };
                    collist.push(colitem);
                }
            }
            this.tableColumn = collist;
            // console.log(collist);
        },
        //弹框过滤input输入事件
        autosearch(evt) {
        if (evt.keyCode != 13 && evt.keyCode != 40 && evt.keyCode != 38) {
            this.filterdata();
            }
        },
        searchkeydown(evt) {
            if (evt.keyCode == 13) {
                // if (this.multiple) {
                //     let crow = this.$refs.ddlcommonTable.getCurrentRow();
                //     this.$refs.ddlcommonTable.toggleRowSelection(crow);
                //     return;
                // } else {
                //     // console.log("按了回车");
                //     this.myvalue = this.$refs.ddlcommonTable.getCurrentRow().hidkey;
                //     if (this.myvalue) {
                //         this.$emit("change", this.$refs.ddlcommonTable.getCurrentRow().hidkey, this.$refs.ddlcommonTable.getCurrentRow().hidname, this.$refs.ddlcommonTable.getCurrentRow());
                //         // this.clearData();
                //     }
                // }
            } else if (evt.keyCode == 40) {
                var cindex = 1;
                this.changeactiverow(cindex);
            } else if (evt.keyCode == 38) {
                var cindex = -1;
                this.changeactiverow(cindex);
            }
        },
        //样本类型弹窗打勾select-config checkMethod 是否可编辑
        // checkGo({row, rowIndex})
        // {
        //      console.log('row ：',row);
        //      console.log('rowIndex ：',rowIndex);
        // },
        //样本类型弹框row事件
        // checkRowClick({row,rowIndex,$rowIndex,column,columnIndex,$columnIndex,cell},event){
        //     console.log('row',row);
        //     console.log('rowIndex',rowIndex);
        //     console.log('$rowIndex',$rowIndex);
        //     console.log('column',column);
        //     console.log('columnIndex',columnIndex);
        //     console.log('$columnIndex',$columnIndex);
        //     console.log('cell',cell);

        // },
        //样本类型弹窗确定按钮绑定事件
        btnok() {

            this.$nextTick(()=>{
            //获取弹窗信息
            let btnokdata = this.$refs.ddlcommonTable.getSelectRecords();
            if (btnokdata) {
                this.$XMsg.alert('样本库ID"'+this.selLibrid+'"的样本类型有'+btnokdata.length+'项');
            }
            console.log('我是btnokdata ：',btnokdata);
            //打开弹窗保存
            // btnokdata.forEach((obj)=>{
            //     this.StorageSmptypeInfo.push(obj);
            // });
            for (let index = 0; index < btnokdata.length; index++) {
                btnokdata[index].ischk = '1';
            }

            this.$tool.setLocalConfig('SMP210_librid_'+this.selLibrid,btnokdata);
            //刷新 vxe-table 样本类型
            // this.
            this.addtypedialogTableVisible = false;

            //loadvxeSpecimenType
            this.loadvxeSpecimenType();
            //刷新样本类型缓存
            this.initSmpDetailRowDisplay();
            });

        },
        //取消
        btncancel() {
            // this.$emit("cancel");
        },

        //样本类型双击ROW
        vxselect(data, evt) {
            // if (this.multiple) {
            //     return;
            // }
            // this.myvalue = data.row.hidkey;
            // this.$emit("change", data.row.hidkey, data.row.hidname, data.row);
            // this.clearData();
        },

         refreshdata() {
            // localStorage.removeItem("RMCOMDDL_" + this.datatype + "_" + this.kindno + "_" + this.instrid);
            let key = "RMCOMDDL_" + (this.datatype ? this.datatype : "") + "_" + (this.kindno ? this.kindno : "") + "_" + (this.instrid ? this.instrid : "") + "_" + (this.rptunitid ? this.rptunitid : "") + "_" + (this.param1 ? this.param1 : "");
            let comdata = this.$ddldata.common_data;

            let dlldataitem = comdata.find((t) => t.key == key);
            if (dlldataitem) {
                comdata.splice(comdata.indexOf(dlldataitem), 1);
                this.$ddldata.common_data = comdata;
            }
            this.loadAllData();
        },
        //grid Row数据筛选
        filterdata() {
            let cData = this.fulldata.Data;
            try {
                if (this.qcode != "") {
                    console.log(this.qcode);
                    cData = cData.filter((item) => item.hidkey.toUpperCase().indexOf(this.qcode.toUpperCase()) > -1 || item.hidname.toUpperCase().indexOf(this.qcode.toUpperCase()) > -1 || item.inputcode.toUpperCase().indexOf(this.qcode.toUpperCase()) > -1);
                }
                if (cData.length > 0) {
                    this.selrow = cData[0];
                } else {
                    this.selrow = {};
                }
                // console.log(this.irrelevant);
                if (this.irrelevant == "deptShowIrrelevant") {
                    //科室显示无关
                    let dept = { deptname: "无关", deptno: "All", depttype: "", hidkey: "All", hidname: "无关", his_deptno: "", inputcode: "WG" };
                    cData.splice(0, 0, dept);
                } else if (this.irrelevant == "specimenShowIrrelevant") {
                    //标本类型显示无关
                    let specimen = { specimen_name: "无关", specimen_code: "All", specimentype: "", hidkey: "All", hidname: "无关", inputcode: "WG", seq: 0 };
                    cData.splice(0, 0, specimen);
                } else if (this.irrelevant == "physicycleShowIrrelevant") {
                    //生理周期显示无关
                    let physicycle = { codena: "无关", codeno: "All", hidkey: "All", hidname: "无关", inputcode: "WG" };
                    cData.splice(0, 0, physicycle);
                }
                this.tableData = cData;
                this.$nextTick(() => {
                    if (this.$refs.ddlcommonTable) {
                        if (this.selrow) {
                            this.$refs.ddlcommonTable.setCurrentRow(this.selrow);
                        }
                    }
                });
            } catch (e) {
                console.log("erro", e);
            }
        },

        /**样本登记明细的方法代码 */
        //初始化样本登记明细的table
        initSmpDetailRowDisplay()
        {
            this.DetailTableData = [];
            //有登记ID
            if (!this.PatientInfo['smp_registerid']) {
               //从样本类型模板获取明细
                if (this.xTableSpecimenTypeV.length>0) {
                    let detailTemplate = this.xTableSpecimenTypeV;
                    for (let index = 0; index < detailTemplate.length; index++) {
                        let element = detailTemplate[index];
                        if (element['ischk']=='1') {
                            let tempRowData = {};
                            tempRowData.ischk = '1';
                            tempRowData.smp_regdetailid = '';
                            tempRowData.smp_registerid = '';
                            //tempRowData.specimen_code = deepTrim(row.smptype);//deepTrim()
                            tempRowData.specimen_code = myTrim(element.specimen_code);
                            tempRowData.specimen_name = myTrim(element.specimen_name);
                            tempRowData.seq =element.seq;
                            tempRowData.smp_quantity = element.volume;
                            tempRowData.smp_type = myTrim(element.specimen_code);
                            tempRowData.smp_number = element.quantity;
                            tempRowData.smp_unit = myTrim(element.unit);
                            tempRowData.isbarcodeprint = '0';
                            this.DetailTableData.push(tempRowData);
                        }
                    }
                }
            }

        },

        //点击上一步、下一步保存明细
        savedetail(isquery)
        {
            if (this.OldPatientInfo['smp_registerid']) {
                this.DetailTableData.forEach((item) => {
                    if (!item['smp_registerid']) {
                        this.$refs.xTableDetail.insert({ smp_registerid: item.smp_regdetailid,
                        smp_registerid: item.smp_registerid, smp_type: item.smp_type,
                        smp_number: item.smp_number, smp_quantity: item.smp_quantity,
                        smp_unit: item.smp_unit , isbarcodeprint: item.isbarcodeprint
                        })
                    }
                });

                    let record =this.$refs.xTableDetail.getRecordset();
                if (record.insertRecords.length>0) {
                    this.$tool
                    .request({
                        url: "SMP/SMP2/SMP210",
                        method: "post",
                        data: {
                            action: "smp_register_save",
                            registerinfo: this.OldPatientInfo,
                            details:this.DetailTableData.length===0?null:record
                        },
                    })
                    .then((response) => {
                        //
                        console.log('保存的信息',response);


                        if (response.errcode == "1") {
                              this.$message({
                                    message: "操作成功！",
                                    type: "success",
                                })
                            if (isquery) {
                            //查询
                            this.smpRegisterQuery();
                            }
                        } else {
                                this.$message({
                                    message:"保存失败！\r" + response.errmsg,
                                    type: "warning",
                                })
                            }
                            return response;
                    })
                    .catch((e) => {
                        console.log("error", e);
                        return e;
                    });
                }
            }

        },
        QueryDetailPrint()
        {
            let RegisterID = this.OldPatientInfo['smp_registerid'];
            if (RegisterID) {
                this.$tool
                .request({
                    url: "SMP/SMP2/SMP210",
                    method: "post",
                    data: {
                        action: "smp_register_query_byid",
                        smp_registerid: RegisterID,
                        librid: this.selLibrid,
                        },
                })
                .then((res) => {
                    this.savePrintDetail(res);

                })
                .catch((error) => {
                    //默认明细
                    this.$message.error("错误1:" + error);
                    console.log("error", error);
                });
            }
        },
        savePrintDetail(res)
        {
            //已有明细
            if (res.RDetail&&this.OldPatientInfo['smp_registerid']) {
                for (let index = 0; index < res.RDetail.Data.length; index++) {
                    res.RDetail.Data[index]['ischk'] ='1';
                }
                    this.DetailTableData= res.RDetail.Data;
                    this.DetailTableData.sort((a, b) => {
                    let seq1 = a.seq
                    let seq2 = b.seq
                    return a.seq - b.seq
                })

                    if (res) {
                    //当前方法内其他请求成功后执行
                    let detail = this.DetailTableData;
                    let printDetail =[];
                    for (let index = 0; index < detail.length; index++) {
                        let element = detail[index];
                        if (element['ischk']=='1') {
                            if (element['isbarcodeprint']=='0')
                                printDetail.push(element);
                        }
                    }
                let registerID = this.OldPatientInfo['smp_registerid'];
                    //打印样本条码信息
                    if (printDetail.length>0&&registerID) {
                        //生成条码
                        this.$tool
                        .request({
                                url: "SMP/SMP2/SMP210",
                            method: "post",
                            data: {
                                action: "createbarcode",
                                details: printDetail,
                            },
                        })
                        .then((res) => {
                        console.log(res);
                        let s = 1;
                        if (res.flag=='1') {
                            let tempCheckArr = [];
                            if (res.isCheckSample) {
                                for (let index = 0; index < res.isCheckSample.Data.length; index++) {
                                    let element = res.isCheckSample.Data[index];
                                    tempCheckArr.push(element['smp_barcode']);
                                }
                            }
                        this.SampleIdKeys = tempCheckArr;

                        //查询明细
                        this.smpDetailQuery(registerID);
                        //提示
                            this.$message({message: "打印成功！",type: "success",})
                        }
                        else
                        {
                            this.$message.error("打印失败:" + res);
                        }
                    })
                    .catch((error) => {
                        //默认明细
                        this.$message.error("错误1:" + error);
                        console.log("error", error);
                    });
                    }

                }
            }
            //默认明细
            else{
                this.initSmpDetailRowDisplay();
            }
            //条码样本信息
            if (res.RSample&&this.OldPatientInfo['smp_registerid']) {
                this.SampleTableData = res.RSample.Data;

            }
        },
        //设置明细行颜色
        rowClassName({ row, rowIndex })
        {
            // //已入库
            // if (row['smp_regdetailid'])
            //  return 'RowFontGreen';
            // //未入库
            // else
            //  return 'RowFontRed';

            //未入库
            if (!row['smp_regdetailid'])
                return 'RowFontRed';
        },

        //双击删除明细
        dbldelDetail({row,rowIndex,$rowIndex,column,columnIndex,$columnIndex,cell},event)
        {
            //target 点击的是checkbox 则跳出事件
            if (column.property=='ischk' || column.property=='isbarcodeprint'||row['isbarcodeprint']=='1'|| event.target.localName=='span') {
                return;
            }
            //调用后台删除方法
            if (row.smp_registerid) {
                //调用后台删除样本库登记信息方法
                this.$tool.request(
                    {
                    url: "SMP/SMP2/SMP210",
                    method: "post",
                    data: {
                        action: "smp_registerdetail_delete",
                        smp_registerid: row.smp_registerid,
                        smp_regdetailid:row.smp_regdetailid
                          },
                    }             )
                .then((res)=>{
                    console.log('删除登记明细成功:',res);
                     console.log('删除的数据:',row);
                    //删除后更新UI
                    let tempdetail = this.DetailTableData;
                    for (let index = 0; index < tempdetail.length; index++) {
                        let element = tempdetail[index];
                        if (element['smp_regdetailid']==row.smp_regdetailid) {
                            this.DetailTableData.splice(index,1);
                            break;
                        }
                    }
                    //this.$refs.xTableDetail.remove(row);
                    //排序
                    this.DetailTableData.sort((a, b) => {
                            let seq1 = a.seq
                            let seq2 = b.seq
                            return a.seq - b.seq
                    })
                    })
                .catch((e)=>{
                    console.log('删除失败:',e);
                    })
            }
            else{
                //根据样本类型选中行删除明细行
                let detailTable  = this.DetailTableData;
                //如果删除的行有明细表ID则需要删除明细表数据
                    for (let index = 0; index < detailTable.length; index++) {
                        let element = detailTable[index];
                        if (element['specimen_code']) {
                            if (element['specimen_code'] ==row['specimen_code']) {
                                this.DetailTableData.splice(index,1);
                                //排序
                                this.DetailTableData.sort((a, b) => {
                                        let seq1 = a.seq
                                        let seq2 = b.seq
                                        return a.seq - b.seq
                                })
                                break;
                            }
                        }
                    }
            }




        },

        /**右键菜单功能模块*/
        //右键菜弹出菜单
        RightClick(e) {

            this.$contextmenu({
                items:  [
                            {
                                label: "删除勾选打印信息",
                                onClick: () => {
                                    this.delSampleInfo('1');
                                },
                                // icon: "el-icon-plus",
                                // disabled: !isA,
                            },
                            {
                                label: "删除全部打印信息",
                                onClick: () => {
                                    this.delSampleInfo('2');
                                },
                                // icon: "el-icon-delete",
                                // disabled: !isD,
                            },
                            // {
                            //     label: "复制",
                            //     onClick: () => {
                            //         this.btnCopy(object, Node);
                            //     },
                            //     icon: "el-icon-document-copy",
                            //     disabled: !isC,
                            // },
                        ],
                // event,
                x: e.clientX + 20,
                y: e.clientY,
                customClass: "RightBack",
                zIndex: 999,
                minWidth: 230,
                // customClass: "background-color: #f8f8f8;border-bottom:solid 1px #e6e6e6",
            });
        },
        //关闭右键菜单
        closeMenu(e) {
            this.RightMenuShow = false;
        },
        //2.1  1:删除(删除打勾的条码信息) 2:强制删除(删除所有打印信息)
        delSampleInfo(option)
        {

            let delSampledata = [];
            //删除勾选信息
            if (option=='1') {
               let tempSampledata = this.$refs.xTableSample.getSelectRecords();
               for (let index = 0; index < tempSampledata.length; index++) {
                   let element = tempSampledata[index];
                   delSampledata.push(element);
               }
                if (delSampledata.length>0) {
                   this.requestDelSmp(delSampledata);
               }
            }
            //删除所有信息
            else if(option=='2')
            {
        　　　　console.log('删除的数据源!',this.SampleTableData);
               let tempSampledata = this.SampleTableData;
               for (let index = 0; index < tempSampledata.length; index++) {
                   let element = tempSampledata[index];
                   delSampledata.push(element);
               }
               if (delSampledata.length>0) {
                   this.requestDelSmp(delSampledata);
               }

            }
        },
        requestDelSmp(delSampledata)
        {
             //1.获取需要删除的样本库登记表主键ID
                let tempdata = this.$refs.xTable.getCurrentRow();
                //调用后台删除方法
                if (tempdata.smp_registerid) {

                    //删除打印信息
                    for (let index = 0; index < delSampledata.length; index++) {
                        let element = delSampledata[index];
                        this.$refs.xTableSample.remove(element);
                    }

                    //this.$refs.xTableSample.updateListenter();

                    let sss =this.$refs.xTableSample.getRecordset();

                    console.log(sss);


                    //调用后台删除样本库登记信息方法
                    this.$tool.request(
                        {
                        url: "SMP/SMP2/SMP210",
                        method: "post",
                        data: {
                            action: "smp_registersample_delete",
                            smp_registerid: tempdata.smp_registerid,
                            smp_sample_data: this.$refs.xTableSample.getRecordset()
                            },
                        }             )
                    .then((res)=>{
                        if(res=='1')
                         this.$message({
                                message: "删除打印信息成功!",
                                type: "success",
                            })
                            /*修改明细table已打印标志checkbox显示 */
                            console.clear()
                            //获取明细table数据
                            let detailData = this.$$refs.xTableDetail.afterFullData
                            console.log(detailData)
                            //获取smp_sample样本信息表删除的登记ID与样本类型代码
                            let printDel = this.$refs.xTableSample.getRecordset()
                            console.log(printDel)
                        })
                    .catch((e)=>{
                        this.$message({
                                message: "删除打印信息失败! 原因:"+e,
                                type: "success",
                            })
                        })
                }
        },

        /*输入字段设置弹窗*/
           OpenConfig() {
            this.$refs.ElementConfig.OpenConfig();
        },

        /**打印标签条码 */
        StartPrintBarcode(cData) {
            if (typeof(jsObj) != undefined&&typeof(jsObj) !== 'undefined') {
                let columnRegister = this.$refs.xTable.getTableColumn().tableColumn;
                let columnSample = this.$refs.xTableSample.getTableColumn().tableColumn;
                let columns = this.$pub.InitColumn(columnRegister.concat(columnSample));
                // columns.push({ title: "创建人", property: "createuser" });
                // columns.push({ title: "创建时间", property: "createdt" });
                let strbase = JSON.stringify(columns);
                strbase += "\r";

                for (let item of cData) {
                   let itemtmp =  Object.assign({},this.OldPatientInfo,item);
                    console.log('item :',itemtmp);
                    console.log('JSON.stringify(itemtmp) ：',JSON.stringify(itemtmp));
                    // let str = strbase + JSON.stringify('['+itemtmp+']');
                    let str = strbase +'['+ JSON.stringify(itemtmp)+']';
                    console.log('strbase + JSON.stringify(itemtmp) ：',str);
                    let sql = btoa(encodeURIComponent(str));
                     console.log(this.barcodestyle);
                    jsObj.PrintCustomJsonReport(this.barcodestyle, sql, this.$tool.getSession(this.$tool.loginusername), "样本信息打印", "");
        }
            } else {
                this.$alert("请使用" + this.$pub.clientname + "", "提示");
            }
        },

        /**打印条码设置 */
         printbarcode(barcodestr, onlybar, cbarno, isreprt) {
            //onlybar  2: 只打印条码 3：只打印回单 其余=都打印
            if (onlybar != "3") {
                if (barcodestr != null && barcodestr != "") {
                    if (this.barcodestyle != "") {
                        //this.$pub.printbarcode(this, barcodestr, "1", this.barcodestyle, this.cxbarcodeprinter, isreprt);
                    } else {
                        this.$alert("没有设置条码的打印样式", "错误", {
                            confirmButtonText: "确定"
                        });
                    }
                }
            }
            // if (this.bPrintBackBill || onlybar == "3") {
            //     if (onlybar != "2") {
            //         if (this.cx_backrpt_style != "") {
            //             if (cbarno.indexOf(",") > -1) {
            //                 cbarno.split(",").forEach(item => {
            //                     if (item != "") {
            //                         this.$pub.printbackbar(this, item, "1", this.cx_backrpt_style, this.pbackmode, this.cx_backrrintername);
            //                     }
            //                 });
            //             } else {
            //                 this.$pub.printbackbar(this, cbarno, "1", this.cx_backrpt_style, this.pbackmode, this.cx_backrrintername);
            //             }
            //         } else {
            //             this.$alert("没有设置回执单的打印样式", "错误", {
            //                 confirmButtonText: "确定"
            //             });
            //         }
            //     }
            // }
        },
        //刷新默认值this.tableDataColumn
        referenceDefault()
        {
            this.QueryCol(1);

            for (let i = 0; i < this.tableDataColumn.length; i++) {
                    if (this.tableDataColumn[i].default_val != "") {
                        this.Queryddl("SMP210_" + this.tableDataColumn[i].col_code, "1");
                    } else {
                        this.tableDataColumn[i].default_valname = "";
                    }
                }
        },


    },
    computed:
    {
        //监听xTableSpecimenTypeV

    },

    watch:
    {
        PatientInfo(val)
        {
            console.log('watch',val);
        }

    },


};
</script>

<style scoped>
.pagetop {
    width: 100%;
    height: 35px;
    display: -webkit-box;
    -webkit-box-pack: center;
    -webkit-box-align: center;
    white-space: nowrap;
    position: absolute;
    z-index: 99;
    overflow-x: auto;
    white-space: nowrap;
}

.pagecenter {
    position: absolute;
    top: 40px;
    width: 100%;
    left: 0;
    bottom: 0px;
    overflow: auto;
}
.pagecenter-left {
    position: absolute;
    height: 100%;
    left: 0;
    width: 50%;
}
.pagecenter-right {
    position: absolute;
    height: 100%;
    width: 50%;
    right: 0px;
}
.pagecenter-left-1 {
    position: absolute;
    height: 40px;
    width: 100%;
    /* margin-top: -5px; */
    margin-top: 0px;
    overflow: hidden;
    /* right: 8px; */
    /* border-bottom: 1px solid #ccc; */

    scroll-behavior: unset;
    border-bottom: 0px solid #ccc;
}

.pagecenter-left-2 {
    /* margin-bottom: -9px; */
    margin-bottom: 0px;
    position: absolute;
    overflow-y: hidden;
    /* top: 9px; */
    height: 320px ;
    width: 1340px;
    /* right: 3px; */
    border: 1px solid #ccc;
}
.pagecenter-left-3 {
    position: absolute;
    top: 429px;
    right: 0px;
    width: 100%;
    bottom: 0px;
}
.pagecenter-left-3-1 {
    position: absolute;
    width: 40%;
    height: 100%;
    border: 1px solid #ccc;

}
.pagecenter-left-3-2 {
    position: absolute;

    width: 60%;
    right: 3px;
    height: 100%;

    border: 1px solid #ccc;
}
table {
    font-size: 12px;
    border-collapse: separate;
    border-spacing: 5px;
    white-space: normal;
    /* margin-left: 10px;; */
}
/*隐藏登记序号、登记日期、样本库滚动条*/
.Corehidden{
    /* overflow: hidden; */
    /* overflow-x: hidden; */
    overflow-y: hidden;

}
/* .ScrollBarhidden::-webkit-scrollbar{
    overflow-y: hidden;
} */
/* .rightTableTop{
    overflow-y: hidden;
} */
/deep/ .upload-img .el-upload--text {
    border: none !important;
    border-radius: 3px !important;
    overflow: inherit !important;
}
/* /deep/.el-image {
    z-index: 2005;
} */
/deep/.el-message-box__wrapper.msgboxtop {
    z-index: 9999;
}
/deep/.el-date-editor.el-input {
    width: auto;
}
::v-deep .tableleft .el-icon-time:before {
    content: "";
}
::v-deep .tableleft .el-input--prefix .el-input__inner {
    padding-left: 5px;
}
::v-deep .tableleft .el-input--suffix .el-input__inner {
    padding-right: 0px;
}
/deep/.el-icon-arrow-down {
    font-size: 12px;
}

/deep/.el-input--small .el-input__icon {
    line-height: 21px !important;
}

/deep/ .el-input__inner
{
    /* text-align: center; */
    /* text-align: inherit; */
    text-align: left;
}

/deep/.el-input--prefix .el-input__inner {
    padding-left: 1px;
    text-align: center;
    /* text-align: left; */
}


/deep/ .vxe-table .vxe-body--column.col-orange {
    background-color: #f8f8f8;
}
/deep/.el-input--suffix .el-input__inner {
    padding-right: 0px;
}

/deep/ .fixedpart{
        overflow-y: hidden;
}

.el-main {
    padding: 0;
}

/deep/.el-dialog__body {
    padding-top: 0px;
    padding-bottom: 0px;
}

/**文本框 */


/**下拉框 */
/deep/.el-input--small .el-input__inner {
    height: 21px !important;
    /* height: 21px !important; */
    line-height: 21px !important;
}

/deep/.el-select .el-input__inner:focus {
    border-color: #409EFF;
}

/**是否单选按钮*/
/deep/.el-radio-button--small .el-radio-button__inner {
    padding: 5px 5px 5px 5px;
    font-size: 12px;
    border-radius: 0;
}

/**样本类型提示语 */
/deep/.vxe-table .vxe-table--empty-block .vxe-table--empty-text {
    display: block;
    width: 100%;
}

/**明细Row已入库 字体颜色 */
/deep/.detailClass .vxe-body--row.RowFontGreen {
    /* background-color: #58e958; */
    color: #58e958;
}
/**明细Row未入库 字体颜色 */
/deep/.detailClass .vxe-body--row.RowFontRed {
    /* background-color: #f53e3e; */
    color: #f53e3e;
}

/deep/ .el-input--mini .el-input__inner {
    line-height: 18px;
    height: 20px;
}
/* /deep/.el-input--mini .el-input__inner {
    height: 20px;
    line-height: 20px;
} */


</style>
